mirror of
https://github.com/microsoft/WSL.git
synced 2026-04-21 03:14:56 -05:00
Replace runtime WSL2_TEST_ONLY()/WSL1_TEST_ONLY() skip macros with TAEF metadata-based test selection. Tests that don't apply to the current WSL version are now excluded by /select: queries at selection time rather than skipped at runtime, eliminating hundreds of 'skipped' results from test output. Changes: - Add WSL2_TEST_METHOD, WSL1_TEST_METHOD, WSLC_TEST_METHOD macros in Common.h that tag tests with WSLVersion metadata property - Convert ~430 test methods across 26 files to use new macros - Update run-tests.ps1 to auto-add /select: version filter - Update CloudTest XML configs with version selection queries - Remove WSL2_TEST_ONLY() from composite macros in NetworkTests.cpp - Update test README with new macro documentation Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
74 lines
2.6 KiB
PowerShell
74 lines
2.6 KiB
PowerShell
#Requires -RunAsAdministrator
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Runs all WSL tests; optionally sets-up a WSL distribution and environment prior to running the tests.
|
|
.PARAMETER Version
|
|
The version of WSL to run the tests in. Defaults to "2".
|
|
.PARAMETER SetupScript
|
|
Path to a setup script to be run prior to running the tests. Defaults to ".\test-setup.ps1".
|
|
.PARAMETER DistroPath
|
|
Path to a .tar/.tar.gz file of the distro to be imported to run the tests with. Defaults to ".\test_distro.tar.gz".
|
|
.PARAMETER TestDataPath
|
|
Path to test data folder. Defaults to ".\test_data".
|
|
.PARAMETER Package
|
|
Path to the wsl.msix package to install. Defaults to ".\wsl.msix".
|
|
.PARAMETER UnitTestsPath
|
|
Path to the linux/unit_tests directory to copy and install the unit tests.
|
|
.PARAMETER PullRequest
|
|
Switch for whether or not this test pass is being run as a part of a pull request; skips certain tests if present. Defaults to $false.
|
|
.PARAMETER TestDllPath
|
|
Path to the TAEF test DLL. Defaults to ".\wsltests.dll".
|
|
.PARAMETER Fast
|
|
Handy flag to skip package and distro installation to make tests run faster during development.
|
|
.PARAMETER TeArgs
|
|
Additional arguments for TE.exe.
|
|
#>
|
|
|
|
[cmdletbinding(PositionalBinding = $false)]
|
|
param (
|
|
[string]$Version = 2,
|
|
[string]$SetupScript = ".\test-setup.ps1",
|
|
[string]$DistroPath = ".\test_distro.tar.gz",
|
|
[string]$TestDataPath = ".\test_data",
|
|
[string]$Package = ".\installer.msix",
|
|
[string]$UnitTestsPath = ".\unit_tests",
|
|
[switch]$PullRequest = $false,
|
|
[string]$TestDllPath = ".\wsltests.dll",
|
|
[switch]$Fast = $false,
|
|
[parameter(ValueFromRemainingArguments = $true)]
|
|
[string[]]$TeArgs
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
if ($Fast)
|
|
{
|
|
$SetupScript = $null
|
|
}
|
|
|
|
$HasUserSelection = $false
|
|
foreach ($arg in $TeArgs)
|
|
{
|
|
if ($arg -like '/name:*' -or $arg -like '/select:*' -or $arg -like '-name:*' -or $arg -like '-select:*')
|
|
{
|
|
$HasUserSelection = $true
|
|
break
|
|
}
|
|
}
|
|
|
|
if ($HasUserSelection)
|
|
{
|
|
te.exe $TestDllPath /p:SetupScript=$SetupScript /p:Version=$Version /p:DistroPath=$DistroPath /p:TestDataPath=$TestDataPath /p:Package=$Package /p:UnitTestsPath=$UnitTestsPath /p:PullRequest=$PullRequest /p:AllowUnsigned=1 @TeArgs
|
|
}
|
|
else
|
|
{
|
|
$env:TAEF_SELECT = "@WSLVersion='$Version' or not(@WSLVersion='*')"
|
|
te.exe $TestDllPath /p:SetupScript=$SetupScript /p:Version=$Version /p:DistroPath=$DistroPath /p:TestDataPath=$TestDataPath /p:Package=$Package /p:UnitTestsPath=$UnitTestsPath /p:PullRequest=$PullRequest /p:AllowUnsigned=1 @TeArgs --% /select:"%TAEF_SELECT%"
|
|
}
|
|
|
|
if (!$?)
|
|
{
|
|
exit 1
|
|
} |