From 88a766601bce85435a3b33386dd94aad01882314 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Sat, 27 Sep 2025 20:35:39 -0700 Subject: [PATCH 01/37] Starting from AI slop --- tools/RunTests-Examples.ps1 | 43 +++++ tools/RunTests.ps1 | 357 ++++++++++++++++++++++++++++++++++++ 2 files changed, 400 insertions(+) create mode 100644 tools/RunTests-Examples.ps1 create mode 100644 tools/RunTests.ps1 diff --git a/tools/RunTests-Examples.ps1 b/tools/RunTests-Examples.ps1 new file mode 100644 index 0000000000..fcd3de98f7 --- /dev/null +++ b/tools/RunTests-Examples.ps1 @@ -0,0 +1,43 @@ +# RunTests.ps1 Usage Examples + +# This file contains examples of how to use the RunTests.ps1 script for development + +# Simplest possible usage - Run tests with all defaults (BuildOutput, x64 Release, no WPR profile) +.\RunTests.ps1 -TestDefName "Deployment" -Test + +# List tests with all defaults +.\RunTests.ps1 -TestDefName "VersionInfoTests" -List + +# Override platform to x86 +.\RunTests.ps1 -TestDefName "PushNotifications" -Platform "x86" -Test + +# Override configuration to Debug +.\RunTests.ps1 -TestDefName "CameraCaptureUI" -Configuration "Debug" -Test + +# Override both platform and configuration +.\RunTests.ps1 -TestDefName "StoragePickerTests" -Platform "x86" -Configuration "Debug" -Test + +# Override output folder (if using different build location) +.\RunTests.ps1 -TestDefName "Deployment" -OutputFolder "MyCustomBuildOutput" -Test + +# Run tests without showing system info +.\RunTests.ps1 -TestDefName "CameraCaptureUI" -ShowSystemInfo:$false -Test + +# Run tests with WPR profile for ETW logging (optional) +.\RunTests.ps1 -TestDefName "Deployment" -wprProfilePath "profile.wprp" -Test + +# Common testdef names you might use: +# - Deployment +# - VersionInfoTests +# - CameraCaptureUI +# - StoragePickerTests +# - PushNotifications +# - AppNotifications +# - DynamicDependency +# - PackageManager +# - And many more... + +# Note: The script will automatically search for the .testdef file in the BuildOutput directory structure +# You only need to provide the TestDefName (without the .testdef extension) +# Default values: OutputFolder=BuildOutput, Platform=x64, Configuration=Release +# The wprProfilePath parameter is optional - if not provided, tests will run without ETW logging \ No newline at end of file diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 new file mode 100644 index 0000000000..78a80085aa --- /dev/null +++ b/tools/RunTests.ps1 @@ -0,0 +1,357 @@ +<# +.SYNOPSIS + Run tests from a specific .testdef file + +.DESCRIPTION + The RunTests script takes a testdef filename (without extension) and runs the tests defined in that + specific .testdef file. This is useful for development when you want to run tests for a specific + component rather than all tests. + + The script searches for the specified .testdef file in the BuildOutput directory structure and + executes the tests according to the testdef configuration. + + *.testdef are JSON files with the same schema as used by TestAll.ps1: + { + "$id": "https://microsoft.com/windowsappsdk/schemas/testdef/2023/08", + + "type": "object", + "properties": { + "Description": { "type": "string" }, + "Type": { "enum": ["TAEF", "Powershell"], "default": "TAEF" }, + "Filename": { "type": "string" }, + "Parameters": { "type": "string" }, + "Architectures": { "type": "array", "items": { "type": "string" } }, + "Status": { "enum": ["Enabled", "Disabled"] }, + }, + "required": ["Description", "Filename", "Architectures", "Status"] + } + +.PARAMETER TestDefName + The name of the .testdef file to run (without the .testdef extension) + Example: "Deployment" to run "Deployment.testdef" + +.PARAMETER OutputFolder + Set the base folder for the script to look for testdefs. Default: BuildOutput + +.PARAMETER Platform + Only run tests for the selected platform (x86, x64, arm64). Default: x64 + +.PARAMETER Configuration + Only run tests for the selected configuration (Debug, Release). Default: Release + +.PARAMETER List + List the tests available in the specified testdef file with their settings + +.PARAMETER Test + Runs the tests available in the specified testdef file + +.PARAMETER ShowSystemInfo + Show system information before running tests (default: true) + +.PARAMETER wprProfilePath + Path to the WPR profile file for ETW logging (optional) + +.EXAMPLE + .\RunTests.ps1 -TestDefName "Deployment" -Test + +.EXAMPLE + .\RunTests.ps1 -TestDefName "PushNotifications" -List + +.EXAMPLE + .\RunTests.ps1 -TestDefName "Deployment" -Platform "x86" -Configuration "Debug" -Test +#> + +param( + [Parameter(Mandatory=$true)] + [string]$TestDefName, + + [Parameter(Mandatory=$false)] + [string]$OutputFolder = "BuildOutput", + + [Parameter(Mandatory=$false)] + [string]$Platform = "x64", + + [Parameter(Mandatory=$false)] + [string]$Configuration = "Release", + + [Parameter(Mandatory=$false)] + [Switch]$Test, + + [Parameter(Mandatory=$false)] + [Switch]$List, + + [Parameter(Mandatory=$false)] + [Switch]$ShowSystemInfo=$true, + + [Parameter(Mandatory=$false)] + [string]$wprProfilePath = "" +) + +$StartTime = Get-Date +$lastexitcode = 0 +Set-StrictMode -Version 3.0 +$ErrorActionPreference = 'Stop' + +function Find-TestDefFile +{ + param($testDefName) + + $configPlat = Join-Path $Configuration $Platform + $outputFolderPath = Join-Path $OutputFolder $configPlat + + $testDefFileName = "$testDefName.testdef" + $testDefFile = Get-ChildItem -Recurse -Filter $testDefFileName $outputFolderPath -ErrorAction SilentlyContinue | Select-Object -First 1 + + if ($null -eq $testDefFile) + { + Write-Error "Could not find testdef file '$testDefFileName' in '$outputFolderPath'" + Exit 1 + } + + Write-Host "Found testdef file: $($testDefFile.FullName)" + return $testDefFile +} + +function Get-Tests +{ + param($testDefFile) + + $tests = @() + $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json + + $count = 0 + $baseId = $testDefFile.BaseName + foreach ($testConfig in $testJson.Tests) + { + $testConfig | Write-Host + if ($testConfig -contains 'Type') + { + $testType = $testConfig.Type + } + else + { + $testType = 'TAEF' + } + + $id = $baseId + "-Test$count" + $t = [PSCustomObject]@{} + $t | Add-Member -MemberType NoteProperty -Name 'Test' -Value $id + $t | Add-Member -MemberType NoteProperty -Name 'Description' -Value $testConfig.Description + $t | Add-Member -MemberType NoteProperty -Name 'Filename' -Value $testConfig.Filename + $t | Add-Member -MemberType NoteProperty -Name 'Parameters' -Value $testConfig.Parameters + $t | Add-Member -MemberType NoteProperty -Name 'Architectures' -Value $testConfig.Architectures + $t | Add-Member -MemberType NoteProperty -Name 'Status' -Value $testConfig.Status + $t | Add-Member -MemberType NoteProperty -Name 'TestDef' -Value $testDefFile.FullName + $t | Add-Member -MemberType NoteProperty -Name 'Type' -Value $testType + + $tests += $t + $count += 1 + } + + $tests +} + +function List-Tests +{ + param($testDefFile) + + $tests = Get-Tests $testDefFile + Write-Host "Tests in $($testDefFile.Name):" + $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 +} + +function Run-TaefTest +{ + param($test) + + $testFolder = Split-Path -parent $test.TestDef + $tePath = Join-Path $testFolder "te.exe" + $dllFile = Join-Path $testFolder $test.Filename + + $teLogFile = (Join-Path $env:Build_SourcesDirectory "BuildOutput\$Configuration\$Platform\Te.wtl") + $teLogPathTo = (Join-Path $env:Build_SourcesDirectory "TestOutput\$Configuration\$Platform") + + # Build the command arguments + $teArgs = @($dllFile, $test.Parameters, "/enableWttLogging", "/appendWttLogging", "/screenCaptureOnError", "/logFile:$teLogFile", "/testMode:EtwLogger") + + # Add ETW logging parameters only if WPR profile is provided + if (-not [string]::IsNullOrEmpty($wprProfilePath)) { + $teArgs += "/EtwLogger:WprProfile=WDGDEPAdex" + $teArgs += "/EtwLogger:SavePoint=TestFailure" + $teArgs += "/EtwLogger:RecordingScope=Execution" + $teArgs += "/EtwLogger:WprProfileFile=$wprProfilePath" + } + + & $tePath $teArgs +} + +function Run-PowershellTest +{ + param($test) + + $testFolder = Split-Path -parent $test.TestDef + $scriptFile = Join-Path $testFolder $test.Filename + + Write-Host "Running PowerShell test: $scriptFile" + if (Test-Path $scriptFile) + { + & $scriptFile $test.Parameters + } + else + { + Write-Error "PowerShell test file not found: $scriptFile" + } +} + +function Run-Tests +{ + param($testDefFile) + + $tests = Get-Tests $testDefFile + Write-Host "Running tests from $($testDefFile.Name)..." + + foreach ($test in $tests) + { + Write-Host "" + Write-Host "=" * 80 + Write-Host "$($test.Filename) - $($test.Description)" + Write-Host "=" * 80 + + $validPlatform = $test.Architectures.Contains($Platform) + $testEnabled = $test.Status -eq "Enabled" + + if ($validPlatform -and $testEnabled) + { + Write-Host "Running test for platform $Platform..." + if ($test.Type -eq 'TAEF') + { + Run-TaefTest $test + } + elseif ($test.Type -eq 'Powershell') + { + Run-PowershellTest $test + } + else + { + Write-Host "Unknown test type '$($test.Type)'. Not running." + Exit 1 + } + } + elseif (-not($validPlatform)) + { + Write-Host "$Platform not listed in supported architectures: $($test.Architectures -join ', ')" + } + elseif (-not($testEnabled)) + { + Write-Host "Test is disabled. Not running." + } + } +} + +function Get-SystemInfo +{ + $regkey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' + $productname = $(Get-Item -Path $regkey).GetValue('ProductName') + $displayversion = $(Get-Item -Path $regkey).GetValue('DisplayVersion') + $currentmajor = $(Get-Item -Path $regkey).GetValue('CurrentMajorVersionNumber') + $currentminor = $(Get-Item -Path $regkey).GetValue('CurrentMinorVersionNumber') + $currentbuild = $(Get-Item -Path $regkey).GetValue('CurrentBuild') + Write-Host "Product : $($productname) $($displayversion) $($currentmajor).$($currentminor).$($currentbuild)" + + $installationtype = $(Get-Item -Path $regkey).GetValue('InstallationType') + Write-Host "InstallationType: $($installationtype)" + + $editionid = $(Get-Item -Path $regkey).GetValue('EditionId') + $compositioneditionid = $(Get-Item -Path $regkey).GetValue('CompositionEditionID') + if ($editionid -eq $compositioneditionid) + { + Write-Host "Edition : $($editionid)" + } + else + { + Write-Host "Edition : $($editionid) [$($compositioneditionid)]" + } + + $buildlabex = $(Get-Item -Path $regkey).GetValue('BuildLabEx') + Write-Host "Build : $($buildlabex)" + + $lcuver = $(Get-Item -Path $regkey).GetValue('LCUVer') + Write-Host "LCU Version : $($lcuver)" + + Write-Host "Powershell : $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)" +} + +# Main script execution +Write-Host "RunTests.ps1 - Running tests for testdef: $TestDefName" +Write-Host "Configuration: $Configuration, Platform: $Platform" +Write-Host "" + +$env:Build_Platform = $Platform.ToLower() +$env:Build_Configuration = $Configuration.ToLower() + +if ($ShowSystemInfo -eq $true) +{ + Get-SystemInfo + Write-Host "" +} + +# Find the testdef file +$testDefFile = Find-TestDefFile $TestDefName + +if ($List -eq $true) +{ + List-Tests $testDefFile | Out-String +} + +if ($Test -eq $true) +{ + $teLogFile = (Join-Path $env:Build_SourcesDirectory "BuildOutput\$Configuration\$Platform\Te.wtl") + $teLogPathTo = (Join-Path $env:Build_SourcesDirectory "TestOutput\$Configuration\$Platform") + remove-item -Path $teLogFile -ErrorAction Ignore + remove-item -Path (Join-path $teLogPathTo "Te.wtl") -ErrorAction Ignore + + Run-Tests $testDefFile + + # Copy test log to TestOutput folder + if (Test-Path -Path $teLogFile) { + Write-Host "Starting copy test log from '$teLogFile'" + + New-Item -ItemType Directory -Path $teLogPathTo -Force + copy-item -Path $teLogFile -Destination $teLogPathTo -Force + + Write-Host "Test log copied to '$teLogPathTo'" + } + + # Copy screenshots to TestOutput folder + $screenshotsFolder = Join-Path $env:Build_SourcesDirectory "WexLogFileOutput" + if (Test-Path -Path $screenshotsFolder) { + Write-Host "Starting copy screenshots from '$screenshotsFolder'" + + # Copy at most 50 screenshots to the upload path. + # In the cases where a large number of tests failed, there is little value in uploading dozens of screenshots + $files = Get-ChildItem -Path $screenshotsFolder -Filter *.jpg | Select-Object -First 50 + foreach($file in $files) + { + Copy-Item $file.FullName $teLogPathTo -Force + } + + # Copy at most 20 tracelogging files to the upload path. + $files = Get-ChildItem -Path $screenshotsFolder -Filter *.etl | Select-Object -First 20 + foreach($file in $files) + { + Copy-Item $file.FullName $teLogPathTo -Force + } + + Write-Host "Test results copied to '$teLogPathTo'" + } + else + { + Write-Host "WexLogFileOutput not found" + } +} + +$TotalTime = (Get-Date)-$StartTime +$TotalMinutes = $TotalTime.Minutes +$TotalSeconds = $TotalTime.Seconds +Write-Host "" +Write-Host "Total Running Time: $TotalMinutes minutes and $TotalSeconds seconds" From 1c425807a56df5aad77f772dd2c64d98596f2c35 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Sat, 27 Sep 2025 22:50:26 -0700 Subject: [PATCH 02/37] Cleaning up AI slop --- tools/RunTests.ps1 | 219 ++++++--------------------------------------- 1 file changed, 28 insertions(+), 191 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 78a80085aa..52d633884d 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -4,29 +4,13 @@ .DESCRIPTION The RunTests script takes a testdef filename (without extension) and runs the tests defined in that - specific .testdef file. This is useful for development when you want to run tests for a specific + specific .testdef file. This is useful for development when you want to run tests for a specific component rather than all tests. The script searches for the specified .testdef file in the BuildOutput directory structure and executes the tests according to the testdef configuration. - *.testdef are JSON files with the same schema as used by TestAll.ps1: - { - "$id": "https://microsoft.com/windowsappsdk/schemas/testdef/2023/08", - - "type": "object", - "properties": { - "Description": { "type": "string" }, - "Type": { "enum": ["TAEF", "Powershell"], "default": "TAEF" }, - "Filename": { "type": "string" }, - "Parameters": { "type": "string" }, - "Architectures": { "type": "array", "items": { "type": "string" } }, - "Status": { "enum": ["Enabled", "Disabled"] }, - }, - "required": ["Description", "Filename", "Architectures", "Status"] - } - -.PARAMETER TestDefName +.PARAMETER TestDef The name of the .testdef file to run (without the .testdef extension) Example: "Deployment" to run "Deployment.testdef" @@ -39,31 +23,19 @@ .PARAMETER Configuration Only run tests for the selected configuration (Debug, Release). Default: Release -.PARAMETER List - List the tests available in the specified testdef file with their settings - -.PARAMETER Test - Runs the tests available in the specified testdef file - -.PARAMETER ShowSystemInfo - Show system information before running tests (default: true) - -.PARAMETER wprProfilePath - Path to the WPR profile file for ETW logging (optional) - -.EXAMPLE - .\RunTests.ps1 -TestDefName "Deployment" -Test +.PARAMETER RunDisabled + If set, will run tests that are marked as "Disabled" in the testdef file. Default: false .EXAMPLE - .\RunTests.ps1 -TestDefName "PushNotifications" -List + .\RunTests.ps1 -TestDef "DeploymentTests" .EXAMPLE - .\RunTests.ps1 -TestDefName "Deployment" -Platform "x86" -Configuration "Debug" -Test + .\RunTests.ps1 -TestDef "Deployment" -Platform "x86" -Configuration "Debug" #> param( [Parameter(Mandatory=$true)] - [string]$TestDefName, + [string]$TestDef, [Parameter(Mandatory=$false)] [string]$OutputFolder = "BuildOutput", @@ -75,39 +47,26 @@ param( [string]$Configuration = "Release", [Parameter(Mandatory=$false)] - [Switch]$Test, - - [Parameter(Mandatory=$false)] - [Switch]$List, - - [Parameter(Mandatory=$false)] - [Switch]$ShowSystemInfo=$true, - - [Parameter(Mandatory=$false)] - [string]$wprProfilePath = "" + [switch]$RunDisabled = $false ) -$StartTime = Get-Date -$lastexitcode = 0 -Set-StrictMode -Version 3.0 -$ErrorActionPreference = 'Stop' - function Find-TestDefFile { param($testDefName) - + $configPlat = Join-Path $Configuration $Platform + $scriptParent = Split-Path -parent $PSScriptRoot + $OutputFolder = Join-Path $scriptParent $OutputFolder $outputFolderPath = Join-Path $OutputFolder $configPlat - $testDefFileName = "$testDefName.testdef" $testDefFile = Get-ChildItem -Recurse -Filter $testDefFileName $outputFolderPath -ErrorAction SilentlyContinue | Select-Object -First 1 - + if ($null -eq $testDefFile) { Write-Error "Could not find testdef file '$testDefFileName' in '$outputFolderPath'" Exit 1 } - + Write-Host "Found testdef file: $($testDefFile.FullName)" return $testDefFile } @@ -154,7 +113,7 @@ function Get-Tests function List-Tests { param($testDefFile) - + $tests = Get-Tests $testDefFile Write-Host "Tests in $($testDefFile.Name):" $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 @@ -168,59 +127,26 @@ function Run-TaefTest $tePath = Join-Path $testFolder "te.exe" $dllFile = Join-Path $testFolder $test.Filename - $teLogFile = (Join-Path $env:Build_SourcesDirectory "BuildOutput\$Configuration\$Platform\Te.wtl") - $teLogPathTo = (Join-Path $env:Build_SourcesDirectory "TestOutput\$Configuration\$Platform") - - # Build the command arguments - $teArgs = @($dllFile, $test.Parameters, "/enableWttLogging", "/appendWttLogging", "/screenCaptureOnError", "/logFile:$teLogFile", "/testMode:EtwLogger") - - # Add ETW logging parameters only if WPR profile is provided - if (-not [string]::IsNullOrEmpty($wprProfilePath)) { - $teArgs += "/EtwLogger:WprProfile=WDGDEPAdex" - $teArgs += "/EtwLogger:SavePoint=TestFailure" - $teArgs += "/EtwLogger:RecordingScope=Execution" - $teArgs += "/EtwLogger:WprProfileFile=$wprProfilePath" - } - - & $tePath $teArgs -} - -function Run-PowershellTest -{ - param($test) - - $testFolder = Split-Path -parent $test.TestDef - $scriptFile = Join-Path $testFolder $test.Filename - - Write-Host "Running PowerShell test: $scriptFile" - if (Test-Path $scriptFile) - { - & $scriptFile $test.Parameters - } - else - { - Write-Error "PowerShell test file not found: $scriptFile" - } + & $tePath $dllFile $test.Parameters } function Run-Tests { param($testDefFile) - + $tests = Get-Tests $testDefFile Write-Host "Running tests from $($testDefFile.Name)..." - + foreach ($test in $tests) { Write-Host "" - Write-Host "=" * 80 Write-Host "$($test.Filename) - $($test.Description)" - Write-Host "=" * 80 - + Write-Host "" + $validPlatform = $test.Architectures.Contains($Platform) $testEnabled = $test.Status -eq "Enabled" - - if ($validPlatform -and $testEnabled) + + if ($validPlatform -and ($testEnabled -or $RunDisabled)) { Write-Host "Running test for platform $Platform..." if ($test.Type -eq 'TAEF') @@ -229,7 +155,8 @@ function Run-Tests } elseif ($test.Type -eq 'Powershell') { - Run-PowershellTest $test + Write-Host "Powershell tests not supported." + Exit 1 } else { @@ -248,107 +175,17 @@ function Run-Tests } } -function Get-SystemInfo -{ - $regkey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' - $productname = $(Get-Item -Path $regkey).GetValue('ProductName') - $displayversion = $(Get-Item -Path $regkey).GetValue('DisplayVersion') - $currentmajor = $(Get-Item -Path $regkey).GetValue('CurrentMajorVersionNumber') - $currentminor = $(Get-Item -Path $regkey).GetValue('CurrentMinorVersionNumber') - $currentbuild = $(Get-Item -Path $regkey).GetValue('CurrentBuild') - Write-Host "Product : $($productname) $($displayversion) $($currentmajor).$($currentminor).$($currentbuild)" - - $installationtype = $(Get-Item -Path $regkey).GetValue('InstallationType') - Write-Host "InstallationType: $($installationtype)" - - $editionid = $(Get-Item -Path $regkey).GetValue('EditionId') - $compositioneditionid = $(Get-Item -Path $regkey).GetValue('CompositionEditionID') - if ($editionid -eq $compositioneditionid) - { - Write-Host "Edition : $($editionid)" - } - else - { - Write-Host "Edition : $($editionid) [$($compositioneditionid)]" - } - - $buildlabex = $(Get-Item -Path $regkey).GetValue('BuildLabEx') - Write-Host "Build : $($buildlabex)" - - $lcuver = $(Get-Item -Path $regkey).GetValue('LCUVer') - Write-Host "LCU Version : $($lcuver)" - - Write-Host "Powershell : $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)" -} - -# Main script execution -Write-Host "RunTests.ps1 - Running tests for testdef: $TestDefName" +Write-Host "RunTests.ps1 - Running tests for testdef: $TestDef" Write-Host "Configuration: $Configuration, Platform: $Platform" Write-Host "" -$env:Build_Platform = $Platform.ToLower() -$env:Build_Configuration = $Configuration.ToLower() - -if ($ShowSystemInfo -eq $true) -{ - Get-SystemInfo - Write-Host "" -} +$StartTime = Get-Date # Find the testdef file -$testDefFile = Find-TestDefFile $TestDefName - -if ($List -eq $true) -{ - List-Tests $testDefFile | Out-String -} +$testDefFile = Find-TestDefFile $TestDef -if ($Test -eq $true) -{ - $teLogFile = (Join-Path $env:Build_SourcesDirectory "BuildOutput\$Configuration\$Platform\Te.wtl") - $teLogPathTo = (Join-Path $env:Build_SourcesDirectory "TestOutput\$Configuration\$Platform") - remove-item -Path $teLogFile -ErrorAction Ignore - remove-item -Path (Join-path $teLogPathTo "Te.wtl") -ErrorAction Ignore - - Run-Tests $testDefFile - - # Copy test log to TestOutput folder - if (Test-Path -Path $teLogFile) { - Write-Host "Starting copy test log from '$teLogFile'" - - New-Item -ItemType Directory -Path $teLogPathTo -Force - copy-item -Path $teLogFile -Destination $teLogPathTo -Force - - Write-Host "Test log copied to '$teLogPathTo'" - } - - # Copy screenshots to TestOutput folder - $screenshotsFolder = Join-Path $env:Build_SourcesDirectory "WexLogFileOutput" - if (Test-Path -Path $screenshotsFolder) { - Write-Host "Starting copy screenshots from '$screenshotsFolder'" - - # Copy at most 50 screenshots to the upload path. - # In the cases where a large number of tests failed, there is little value in uploading dozens of screenshots - $files = Get-ChildItem -Path $screenshotsFolder -Filter *.jpg | Select-Object -First 50 - foreach($file in $files) - { - Copy-Item $file.FullName $teLogPathTo -Force - } - - # Copy at most 20 tracelogging files to the upload path. - $files = Get-ChildItem -Path $screenshotsFolder -Filter *.etl | Select-Object -First 20 - foreach($file in $files) - { - Copy-Item $file.FullName $teLogPathTo -Force - } - - Write-Host "Test results copied to '$teLogPathTo'" - } - else - { - Write-Host "WexLogFileOutput not found" - } -} +List-Tests $testDefFile +Run-Tests $testDefFile $TotalTime = (Get-Date)-$StartTime $TotalMinutes = $TotalTime.Minutes From 7ab8869117f7282039b8f4199d79214d6288a526 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Sat, 27 Sep 2025 22:51:24 -0700 Subject: [PATCH 03/37] Deleting other folder --- tools/RunTests-Examples.ps1 | 43 ------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 tools/RunTests-Examples.ps1 diff --git a/tools/RunTests-Examples.ps1 b/tools/RunTests-Examples.ps1 deleted file mode 100644 index fcd3de98f7..0000000000 --- a/tools/RunTests-Examples.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -# RunTests.ps1 Usage Examples - -# This file contains examples of how to use the RunTests.ps1 script for development - -# Simplest possible usage - Run tests with all defaults (BuildOutput, x64 Release, no WPR profile) -.\RunTests.ps1 -TestDefName "Deployment" -Test - -# List tests with all defaults -.\RunTests.ps1 -TestDefName "VersionInfoTests" -List - -# Override platform to x86 -.\RunTests.ps1 -TestDefName "PushNotifications" -Platform "x86" -Test - -# Override configuration to Debug -.\RunTests.ps1 -TestDefName "CameraCaptureUI" -Configuration "Debug" -Test - -# Override both platform and configuration -.\RunTests.ps1 -TestDefName "StoragePickerTests" -Platform "x86" -Configuration "Debug" -Test - -# Override output folder (if using different build location) -.\RunTests.ps1 -TestDefName "Deployment" -OutputFolder "MyCustomBuildOutput" -Test - -# Run tests without showing system info -.\RunTests.ps1 -TestDefName "CameraCaptureUI" -ShowSystemInfo:$false -Test - -# Run tests with WPR profile for ETW logging (optional) -.\RunTests.ps1 -TestDefName "Deployment" -wprProfilePath "profile.wprp" -Test - -# Common testdef names you might use: -# - Deployment -# - VersionInfoTests -# - CameraCaptureUI -# - StoragePickerTests -# - PushNotifications -# - AppNotifications -# - DynamicDependency -# - PackageManager -# - And many more... - -# Note: The script will automatically search for the .testdef file in the BuildOutput directory structure -# You only need to provide the TestDefName (without the .testdef extension) -# Default values: OutputFolder=BuildOutput, Platform=x64, Configuration=Release -# The wprProfilePath parameter is optional - if not provided, tests will run without ETW logging \ No newline at end of file From be3f0e4ebc62a398346804ef0927baa688165b16 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Sat, 27 Sep 2025 22:59:24 -0700 Subject: [PATCH 04/37] Adding cmd file --- tools/RunTests.cmd | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tools/RunTests.cmd diff --git a/tools/RunTests.cmd b/tools/RunTests.cmd new file mode 100644 index 0000000000..de5add0d2a --- /dev/null +++ b/tools/RunTests.cmd @@ -0,0 +1,5 @@ +@echo off + +powershell -ExecutionPolicy Unrestricted -NoLogo -NoProfile -File %~dp0\tools\RunTests.ps1 %* + +exit /b %ERRORLEVEL% From 263b4acfcbb857d9d3c24dab3b7774a032ff531b Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 09:10:02 -0700 Subject: [PATCH 05/37] Renaming outputFolder to output --- tools/RunTests.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 52d633884d..a25c0218d3 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -14,7 +14,7 @@ The name of the .testdef file to run (without the .testdef extension) Example: "Deployment" to run "Deployment.testdef" -.PARAMETER OutputFolder +.PARAMETER Output Set the base folder for the script to look for testdefs. Default: BuildOutput .PARAMETER Platform @@ -37,8 +37,8 @@ param( [Parameter(Mandatory=$true)] [string]$TestDef, - [Parameter(Mandatory=$false)] - [string]$OutputFolder = "BuildOutput", + [Parameter] + [string]$Output = "BuildOutput", [Parameter(Mandatory=$false)] [string]$Platform = "x64", @@ -56,8 +56,8 @@ function Find-TestDefFile $configPlat = Join-Path $Configuration $Platform $scriptParent = Split-Path -parent $PSScriptRoot - $OutputFolder = Join-Path $scriptParent $OutputFolder - $outputFolderPath = Join-Path $OutputFolder $configPlat + $Output = Join-Path $scriptParent $Output + $outputFolderPath = Join-Path $Output $configPlat $testDefFileName = "$testDefName.testdef" $testDefFile = Get-ChildItem -Recurse -Filter $testDefFileName $outputFolderPath -ErrorAction SilentlyContinue | Select-Object -First 1 From 8071b279f9575f0c6c6a87be2b47e13d207988ca Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 09:10:47 -0700 Subject: [PATCH 06/37] Removing mandatory false from arguments --- tools/RunTests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index a25c0218d3..f7dfcb1a14 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -40,13 +40,13 @@ param( [Parameter] [string]$Output = "BuildOutput", - [Parameter(Mandatory=$false)] + [Parameter] [string]$Platform = "x64", - [Parameter(Mandatory=$false)] + [Parameter] [string]$Configuration = "Release", - [Parameter(Mandatory=$false)] + [Parameter] [switch]$RunDisabled = $false ) From 8f45946c216d410d48107fffc0473ca6d1ee6487 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 09:11:25 -0700 Subject: [PATCH 07/37] Defaulting to host machine archtecture --- tools/RunTests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index f7dfcb1a14..0c031c150e 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -41,7 +41,7 @@ param( [string]$Output = "BuildOutput", [Parameter] - [string]$Platform = "x64", + [string]$Platform = "$($env:PROCESSOR_ARCHITECTURE)", [Parameter] [string]$Configuration = "Release", From 62fe6aaa932620429ea030c25556958f48b79e92 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 09:13:20 -0700 Subject: [PATCH 08/37] Restricting to allowed values --- tools/RunTests.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 0c031c150e..0eb54dab31 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -41,9 +41,11 @@ param( [string]$Output = "BuildOutput", [Parameter] + [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] [string]$Platform = "$($env:PROCESSOR_ARCHITECTURE)", [Parameter] + [ValidateSet("Release", "Debug", IgnoreCase=$true)] [string]$Configuration = "Release", [Parameter] From 1a8ab9a78ddd077b4bb6cadacddeadaedb031ffc Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 09:24:16 -0700 Subject: [PATCH 09/37] Removing unecessarry parameter annotation --- tools/RunTests.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 0eb54dab31..300dd3096a 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -37,18 +37,14 @@ param( [Parameter(Mandatory=$true)] [string]$TestDef, - [Parameter] [string]$Output = "BuildOutput", - [Parameter] [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] [string]$Platform = "$($env:PROCESSOR_ARCHITECTURE)", - [Parameter] [ValidateSet("Release", "Debug", IgnoreCase=$true)] [string]$Configuration = "Release", - [Parameter] [switch]$RunDisabled = $false ) @@ -181,6 +177,11 @@ Write-Host "RunTests.ps1 - Running tests for testdef: $TestDef" Write-Host "Configuration: $Configuration, Platform: $Platform" Write-Host "" +if ($Platform -eq "AMD64") +{ + $Platform = "x64" +} + $StartTime = Get-Date # Find the testdef file From fb8a250eefe7af818eabf08a3412540c496bccb3 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 10:20:08 -0700 Subject: [PATCH 10/37] Adding building tests --- tools/RunTests.ps1 | 65 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 300dd3096a..2308c5d1b3 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -18,7 +18,7 @@ Set the base folder for the script to look for testdefs. Default: BuildOutput .PARAMETER Platform - Only run tests for the selected platform (x86, x64, arm64). Default: x64 + Only run tests for the selected platform (x86, x64, arm64). Default: the current architecture .PARAMETER Configuration Only run tests for the selected configuration (Debug, Release). Default: Release @@ -50,12 +50,12 @@ param( function Find-TestDefFile { - param($testDefName) + param( + $testDefName, + $baseFolder + ) - $configPlat = Join-Path $Configuration $Platform - $scriptParent = Split-Path -parent $PSScriptRoot - $Output = Join-Path $scriptParent $Output - $outputFolderPath = Join-Path $Output $configPlat + $outputFolderPath = Join-Path $baseFolder $configPlat $testDefFileName = "$testDefName.testdef" $testDefFile = Get-ChildItem -Recurse -Filter $testDefFileName $outputFolderPath -ErrorAction SilentlyContinue | Select-Object -First 1 @@ -69,6 +69,28 @@ function Find-TestDefFile return $testDefFile } +function Build-Tests +{ + param( + $testDefFile, + $msbuildPath + ) + + $testFolder = Split-Path -parent $testDefFile + Write-Host "Building tests in folder: $testFolder" + $projFile = Get-ChildItem -Filter "*.vcxproj" -Path $testFolder | Select-Object -First 1 + + if ($null -eq $projFile) + { + Write-Error "Could not find a .vcxproj file in $testFolder" + Exit 1 + } + + Write-Host "Found project file: $projFile" + + & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform +} + function Get-Tests { param($testDefFile) @@ -173,19 +195,40 @@ function Run-Tests } } -Write-Host "RunTests.ps1 - Running tests for testdef: $TestDef" -Write-Host "Configuration: $Configuration, Platform: $Platform" -Write-Host "" - if ($Platform -eq "AMD64") { $Platform = "x64" } +$scriptParent = Split-Path -parent $PSScriptRoot + +Write-Host "Building tests from testdef: $TestDef" + +$VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath +Write-Host "VCToolsInstallDir: $VCToolsInstallDir" + +$msbuildPath = Join-Path $VCToolsInstallDir "MSBuild\Current\Bin\msbuild.exe" +Write-Host "MSBuild Path: $msbuildPath" + +$testsSourceFolder = Join-Path $scriptParent "test" +Write-Host "Tests source folder: $testsSourceFolder" + +$sourceTestDefFile = Find-TestDefFile $TestDef $testsSourceFolder + +Build-Tests $sourceTestDefFile $msbuildPath + +Write-Host "RunTests.ps1 - Running tests for testdef: $TestDef" +Write-Host "Configuration: $Configuration, Platform: $Platform" +Write-Host "" + + $StartTime = Get-Date # Find the testdef file -$testDefFile = Find-TestDefFile $TestDef +$configPlat = Join-Path $Configuration $Platform +$outputFolder = Join-Path $scriptParent $Output + +$testDefFile = Find-TestDefFile $TestDef $outputFolder List-Tests $testDefFile Run-Tests $testDefFile From e6268f422985b9c4ebbd4c86d4c705a3ccc9c5ca Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 10:20:52 -0700 Subject: [PATCH 11/37] Adding comments with better description --- tools/RunTests.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 2308c5d1b3..7386bc25c8 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -1,14 +1,15 @@ <# .SYNOPSIS - Run tests from a specific .testdef file + Build and run tests from a specific .testdef file .DESCRIPTION - The RunTests script takes a testdef filename (without extension) and runs the tests defined in that - specific .testdef file. This is useful for development when you want to run tests for a specific - component rather than all tests. + The BuildAndRunTests script takes a testdef filename (without extension) and build then runs + the tests defined in that specific .testdef file. This is useful for development when you want + to run tests for a specific component rather than all tests. - The script searches for the specified .testdef file in the BuildOutput directory structure and - executes the tests according to the testdef configuration. + The script searches for the specified .testdef file in the test directory structure and + builds the associated test project. It then finds the .testdef file in the output directory, + lists the tests defined in the .testdef file and executes the tests according to the testdef configuration. .PARAMETER TestDef The name of the .testdef file to run (without the .testdef extension) @@ -217,6 +218,7 @@ $sourceTestDefFile = Find-TestDefFile $TestDef $testsSourceFolder Build-Tests $sourceTestDefFile $msbuildPath +Write-Host "" Write-Host "RunTests.ps1 - Running tests for testdef: $TestDef" Write-Host "Configuration: $Configuration, Platform: $Platform" Write-Host "" From c8249c109a564e6b1c6d1cb8ae51bb6cf633def5 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 10:46:52 -0700 Subject: [PATCH 12/37] Moving msbuild path to inside function --- tools/RunTests.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 7386bc25c8..6c5dd1b864 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -73,10 +73,15 @@ function Find-TestDefFile function Build-Tests { param( - $testDefFile, - $msbuildPath + $testDefFile ) + $VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath + Write-Host "VCToolsInstallDir: $VCToolsInstallDir" + + $msbuildPath = Join-Path $VCToolsInstallDir "MSBuild\Current\Bin\msbuild.exe" + Write-Host "MSBuild Path: $msbuildPath" + $testFolder = Split-Path -parent $testDefFile Write-Host "Building tests in folder: $testFolder" $projFile = Get-ChildItem -Filter "*.vcxproj" -Path $testFolder | Select-Object -First 1 @@ -89,7 +94,7 @@ function Build-Tests Write-Host "Found project file: $projFile" - & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform + # & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform } function Get-Tests @@ -205,18 +210,13 @@ $scriptParent = Split-Path -parent $PSScriptRoot Write-Host "Building tests from testdef: $TestDef" -$VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath -Write-Host "VCToolsInstallDir: $VCToolsInstallDir" - -$msbuildPath = Join-Path $VCToolsInstallDir "MSBuild\Current\Bin\msbuild.exe" -Write-Host "MSBuild Path: $msbuildPath" $testsSourceFolder = Join-Path $scriptParent "test" Write-Host "Tests source folder: $testsSourceFolder" $sourceTestDefFile = Find-TestDefFile $TestDef $testsSourceFolder -Build-Tests $sourceTestDefFile $msbuildPath +Build-Tests $sourceTestDefFile Write-Host "" Write-Host "RunTests.ps1 - Running tests for testdef: $TestDef" From f19cfd69e903dd27d4694d117fbede780b1e64dc Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 10:56:35 -0700 Subject: [PATCH 13/37] cleaning up the script --- tools/RunTests.ps1 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 6c5dd1b864..511d912161 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -56,13 +56,15 @@ function Find-TestDefFile $baseFolder ) - $outputFolderPath = Join-Path $baseFolder $configPlat $testDefFileName = "$testDefName.testdef" - $testDefFile = Get-ChildItem -Recurse -Filter $testDefFileName $outputFolderPath -ErrorAction SilentlyContinue | Select-Object -First 1 + + Write-Host "Searching for testdef file '$testDefFileName' in '$baseFolder'..." + + $testDefFile = Get-ChildItem -Recurse -Filter $testDefFileName $baseFolder -ErrorAction SilentlyContinue | Select-Object -First 1 if ($null -eq $testDefFile) { - Write-Error "Could not find testdef file '$testDefFileName' in '$outputFolderPath'" + Write-Error "Could not find testdef file '$testDefFileName' in '$baseFolder'" Exit 1 } @@ -94,7 +96,7 @@ function Build-Tests Write-Host "Found project file: $projFile" - # & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform + & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform } function Get-Tests @@ -206,10 +208,13 @@ if ($Platform -eq "AMD64") $Platform = "x64" } -$scriptParent = Split-Path -parent $PSScriptRoot +Write-Host "Configuration: $Configuration, Platform: $Platform" -Write-Host "Building tests from testdef: $TestDef" +$scriptParent = Split-Path -parent $PSScriptRoot +Write-Host "" +Write-Host "Building tests from testdef: $TestDef" -ForegroundColor Yellow +Write-Host "" $testsSourceFolder = Join-Path $scriptParent "test" Write-Host "Tests source folder: $testsSourceFolder" @@ -219,16 +224,14 @@ $sourceTestDefFile = Find-TestDefFile $TestDef $testsSourceFolder Build-Tests $sourceTestDefFile Write-Host "" -Write-Host "RunTests.ps1 - Running tests for testdef: $TestDef" -Write-Host "Configuration: $Configuration, Platform: $Platform" +Write-Host "Running tests for testdef: $TestDef" -ForegroundColor Yellow Write-Host "" $StartTime = Get-Date -# Find the testdef file $configPlat = Join-Path $Configuration $Platform -$outputFolder = Join-Path $scriptParent $Output +$outputFolder = Join-Path $scriptParent $Output $configPlat $testDefFile = Find-TestDefFile $TestDef $outputFolder From 17c7b369f80fec9ff78df28e2c128b55f90ac746 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 11:25:31 -0700 Subject: [PATCH 14/37] Setting build verbosity to minimal --- tools/RunTests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 511d912161..582a270d3b 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -96,7 +96,7 @@ function Build-Tests Write-Host "Found project file: $projFile" - & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform + & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform /v:minimal } function Get-Tests From 012c0dd439d45e86c06a50356f4bcec1e4898e8f Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 12:41:32 -0700 Subject: [PATCH 15/37] Removing some lines --- tools/RunTests.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 582a270d3b..89f17d429c 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -217,24 +217,20 @@ Write-Host "Building tests from testdef: $TestDef" -ForegroundColor Yellow Write-Host "" $testsSourceFolder = Join-Path $scriptParent "test" -Write-Host "Tests source folder: $testsSourceFolder" $sourceTestDefFile = Find-TestDefFile $TestDef $testsSourceFolder - Build-Tests $sourceTestDefFile Write-Host "" Write-Host "Running tests for testdef: $TestDef" -ForegroundColor Yellow Write-Host "" - $StartTime = Get-Date $configPlat = Join-Path $Configuration $Platform $outputFolder = Join-Path $scriptParent $Output $configPlat $testDefFile = Find-TestDefFile $TestDef $outputFolder - List-Tests $testDefFile Run-Tests $testDefFile From 44fb93914129aa3b6705985a51dd326268b9fd28 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 17:15:52 -0700 Subject: [PATCH 16/37] Adding filters in parameters --- tools/RunTests.ps1 | 214 ++++++++++++++++++++++----------------------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 89f17d429c..41a9908f33 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -1,43 +1,7 @@ <# -.SYNOPSIS - Build and run tests from a specific .testdef file - -.DESCRIPTION - The BuildAndRunTests script takes a testdef filename (without extension) and build then runs - the tests defined in that specific .testdef file. This is useful for development when you want - to run tests for a specific component rather than all tests. - - The script searches for the specified .testdef file in the test directory structure and - builds the associated test project. It then finds the .testdef file in the output directory, - lists the tests defined in the .testdef file and executes the tests according to the testdef configuration. - -.PARAMETER TestDef - The name of the .testdef file to run (without the .testdef extension) - Example: "Deployment" to run "Deployment.testdef" - -.PARAMETER Output - Set the base folder for the script to look for testdefs. Default: BuildOutput - -.PARAMETER Platform - Only run tests for the selected platform (x86, x64, arm64). Default: the current architecture - -.PARAMETER Configuration - Only run tests for the selected configuration (Debug, Release). Default: Release - -.PARAMETER RunDisabled - If set, will run tests that are marked as "Disabled" in the testdef file. Default: false - -.EXAMPLE - .\RunTests.ps1 -TestDef "DeploymentTests" - -.EXAMPLE - .\RunTests.ps1 -TestDef "Deployment" -Platform "x86" -Configuration "Debug" #> param( - [Parameter(Mandatory=$true)] - [string]$TestDef, - [string]$Output = "BuildOutput", [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] @@ -46,36 +10,27 @@ param( [ValidateSet("Release", "Debug", IgnoreCase=$true)] [string]$Configuration = "Release", - [switch]$RunDisabled = $false -) + [switch]$RunDisabled = $false, -function Find-TestDefFile -{ - param( - $testDefName, - $baseFolder - ) + [switch]$Build = $false, - $testDefFileName = "$testDefName.testdef" + [string]$FilterTestDef, - Write-Host "Searching for testdef file '$testDefFileName' in '$baseFolder'..." + [string]$FilterDescription, - $testDefFile = Get-ChildItem -Recurse -Filter $testDefFileName $baseFolder -ErrorAction SilentlyContinue | Select-Object -First 1 + [string]$FilterFilename, - if ($null -eq $testDefFile) - { - Write-Error "Could not find testdef file '$testDefFileName' in '$baseFolder'" - Exit 1 - } + [string]$IgnoreFilename, - Write-Host "Found testdef file: $($testDefFile.FullName)" - return $testDefFile -} + [string]$FilterParameters, + + [string]$CustomParameters +) function Build-Tests { param( - $testDefFile + $tests ) $VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath @@ -84,55 +39,102 @@ function Build-Tests $msbuildPath = Join-Path $VCToolsInstallDir "MSBuild\Current\Bin\msbuild.exe" Write-Host "MSBuild Path: $msbuildPath" - $testFolder = Split-Path -parent $testDefFile - Write-Host "Building tests in folder: $testFolder" - $projFile = Get-ChildItem -Filter "*.vcxproj" -Path $testFolder | Select-Object -First 1 + # Build each test project once + $projectsBuilt = @{} - if ($null -eq $projFile) + foreach ($test in $tests) { - Write-Error "Could not find a .vcxproj file in $testFolder" - Exit 1 - } + $testDefFile = $test.TestDef + Write-Host "Building tests for testdef: $testDefFile" - Write-Host "Found project file: $projFile" + $testFolder = Split-Path -parent $testDefFile + Write-Host "Building tests in folder: $testFolder" + $projFile = Get-ChildItem -Filter "*.vcxproj" -Path $testFolder | Select-Object -First 1 - & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform /v:minimal + if ($null -eq $projFile) + { + Write-Error "Could not find a .vcxproj file in $testFolder" + Exit 1 + } + + Write-Host "Found project file: $projFile" + + if ($projectsBuilt.ContainsKey($projFile.FullName)) + { + Write-Host "Project already built. Skipping." + continue + } + + & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform /v:minimal + $projectsBuilt[$projFile.FullName] = $true + } } function Get-Tests { - param($testDefFile) + param($baseFolder) $tests = @() - $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json - $count = 0 - $baseId = $testDefFile.BaseName - foreach ($testConfig in $testJson.Tests) + $testDefs = Get-ChildItem -Recurse -Filter "*.testdef" $baseFolder -ErrorAction SilentlyContinue + + foreach ($testDefFile in $testDefs) { - $testConfig | Write-Host - if ($testConfig -contains 'Type') + $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json + $count = 0 + foreach ($testConfig in $testJson.Tests) { - $testType = $testConfig.Type - } - else - { - $testType = 'TAEF' - } + # Apply filters + # If a filter is set and the test property does not contain the filter regex, skip this test + if ($FilterTestDef -and ($testDefFile.FullName -notmatch $FilterTestDef)) + { + continue + } + + if ($FilterDescription -and ($testConfig.Description -notmatch $FilterDescription)) + { + continue + } - $id = $baseId + "-Test$count" - $t = [PSCustomObject]@{} - $t | Add-Member -MemberType NoteProperty -Name 'Test' -Value $id - $t | Add-Member -MemberType NoteProperty -Name 'Description' -Value $testConfig.Description - $t | Add-Member -MemberType NoteProperty -Name 'Filename' -Value $testConfig.Filename - $t | Add-Member -MemberType NoteProperty -Name 'Parameters' -Value $testConfig.Parameters - $t | Add-Member -MemberType NoteProperty -Name 'Architectures' -Value $testConfig.Architectures - $t | Add-Member -MemberType NoteProperty -Name 'Status' -Value $testConfig.Status - $t | Add-Member -MemberType NoteProperty -Name 'TestDef' -Value $testDefFile.FullName - $t | Add-Member -MemberType NoteProperty -Name 'Type' -Value $testType - - $tests += $t - $count += 1 + if ($FilterFilename -and ($testConfig.Filename -notmatch $FilterFilename)) + { + continue + } + + if ($IgnoreFilename -and ($testConfig.Filename -match $IgnoreFilename)) + { + continue + } + + if ($FilterParameters -and ($testConfig.Parameters -notmatch $FilterParameters)) + { + continue + } + + if ($testConfig -contains 'Type') + { + $testType = $testConfig.Type + } + else + { + $testType = 'TAEF' + } + + $baseId = $testDefFile.BaseName + $id = $baseId + "-Test$count" + $t = [PSCustomObject]@{} + $t | Add-Member -MemberType NoteProperty -Name 'Test' -Value $id + $t | Add-Member -MemberType NoteProperty -Name 'Description' -Value $testConfig.Description + $t | Add-Member -MemberType NoteProperty -Name 'Filename' -Value $testConfig.Filename + $t | Add-Member -MemberType NoteProperty -Name 'Parameters' -Value $testConfig.Parameters + $t | Add-Member -MemberType NoteProperty -Name 'Architectures' -Value $testConfig.Architectures + $t | Add-Member -MemberType NoteProperty -Name 'Status' -Value $testConfig.Status + $t | Add-Member -MemberType NoteProperty -Name 'TestDef' -Value $testDefFile.FullName + $t | Add-Member -MemberType NoteProperty -Name 'Type' -Value $testType + + $tests += $t + $count += 1 + } } $tests @@ -140,10 +142,8 @@ function Get-Tests function List-Tests { - param($testDefFile) + param($tests) - $tests = Get-Tests $testDefFile - Write-Host "Tests in $($testDefFile.Name):" $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 } @@ -160,10 +160,7 @@ function Run-TaefTest function Run-Tests { - param($testDefFile) - - $tests = Get-Tests $testDefFile - Write-Host "Running tests from $($testDefFile.Name)..." + param($tests) foreach ($test in $tests) { @@ -212,14 +209,17 @@ Write-Host "Configuration: $Configuration, Platform: $Platform" $scriptParent = Split-Path -parent $PSScriptRoot -Write-Host "" -Write-Host "Building tests from testdef: $TestDef" -ForegroundColor Yellow -Write-Host "" +if ($Build) +{ + Write-Host "" + Write-Host "Building tests" + Write-Host "" -$testsSourceFolder = Join-Path $scriptParent "test" + $testsSourceFolder = Join-Path $scriptParent "test" -$sourceTestDefFile = Find-TestDefFile $TestDef $testsSourceFolder -Build-Tests $sourceTestDefFile + $tests = Get-Tests $testsSourceFolder + Build-Tests $tests +} Write-Host "" Write-Host "Running tests for testdef: $TestDef" -ForegroundColor Yellow @@ -230,9 +230,9 @@ $StartTime = Get-Date $configPlat = Join-Path $Configuration $Platform $outputFolder = Join-Path $scriptParent $Output $configPlat -$testDefFile = Find-TestDefFile $TestDef $outputFolder -List-Tests $testDefFile -Run-Tests $testDefFile +$tests = Get-Tests $outputFolder +List-Tests $tests +Run-Tests $tests $TotalTime = (Get-Date)-$StartTime $TotalMinutes = $TotalTime.Minutes From 40502cfa20bd0f7315443cf934f0733651954678 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 18:12:01 -0700 Subject: [PATCH 17/37] Adding more parameters --- tools/RunTests.ps1 | 60 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 41a9908f33..b84ba6df83 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -24,7 +24,25 @@ param( [string]$FilterParameters, - [string]$CustomParameters + [string]$CustomParameters, + + [string]$LogFile, + + [switch]$EnableETWLogging = $false, + + [switch]$AppendWttLogging = $false, + + [string]$LogFile, + + [string]$TestMode, + + [string]$WprProfile, + + [string]$EtwLoggerSavePoint, + + [string]$EtwLoggerRecordingScope, + + [string]$WprProfilePath ) function Build-Tests @@ -155,7 +173,45 @@ function Run-TaefTest $tePath = Join-Path $testFolder "te.exe" $dllFile = Join-Path $testFolder $test.Filename - & $tePath $dllFile $test.Parameters + if ($CustomParameters) + { + $test.Parameters = $CustomParameters + } + + $additionalParams = "" + + if ($LogFile) + { + $additionalParams += " /LogFile $LogFile" + } + + if ($EnableETWLogging) + { + $additionalParams += " /enableEtwLogging" + + if ($WprProfile) + { + $additionalParams += " /EtwLogger:WprProfile=$WprProfile" + } + + if ($EtwLoggerSavePoint) + { + $additionalParams += " /EtwLogger:SavePoint=$EtwLoggerSavePoint" + } + + if ($EtwLoggerRecordingScope) + { + $additionalParams += " /EtwLogger:RecordingScope=$EtwLoggerRecordingScope" + } + + if ($WprProfilePath) + { + $additionalParams += " /EtwLogger:WprProfileFile=$WprProfilePath" + } + } + + + & $tePath $dllFile $test.Parameters $additionalParams } function Run-Tests From 2b1bd8c72dc86eb0bd314daa39d5d975e1ca96bc Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 18:40:40 -0700 Subject: [PATCH 18/37] Fixing parameters and filtering --- tools/RunTests.ps1 | 120 +++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 76 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index b84ba6df83..2d2330d805 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -32,8 +32,6 @@ param( [switch]$AppendWttLogging = $false, - [string]$LogFile, - [string]$TestMode, [string]$WprProfile, @@ -92,70 +90,40 @@ function Get-Tests { param($baseFolder) - $tests = @() - $testDefs = Get-ChildItem -Recurse -Filter "*.testdef" $baseFolder -ErrorAction SilentlyContinue - foreach ($testDefFile in $testDefs) + $allTests = foreach ($testDefFile in $testDefs) { $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json $count = 0 + foreach ($testConfig in $testJson.Tests) { - # Apply filters - # If a filter is set and the test property does not contain the filter regex, skip this test - if ($FilterTestDef -and ($testDefFile.FullName -notmatch $FilterTestDef)) - { - continue - } - - if ($FilterDescription -and ($testConfig.Description -notmatch $FilterDescription)) - { - continue - } - - if ($FilterFilename -and ($testConfig.Filename -notmatch $FilterFilename)) - { - continue - } - - if ($IgnoreFilename -and ($testConfig.Filename -match $IgnoreFilename)) - { - continue - } - - if ($FilterParameters -and ($testConfig.Parameters -notmatch $FilterParameters)) - { - continue - } - - if ($testConfig -contains 'Type') - { - $testType = $testConfig.Type - } - else - { - $testType = 'TAEF' + $baseId = $testDefFile.BaseName + $testType = if ($testConfig.PSObject.Properties['Type']) { $testConfig.Type } else { 'TAEF' } + + [PSCustomObject]@{ + Test = "$baseId-Test$count" + Description = $testConfig.Description + Filename = $testConfig.Filename + Parameters = $testConfig.Parameters + Architectures = $testConfig.Architectures + Status = $testConfig.Status + TestDef = $testDefFile.FullName + Type = $testType } - $baseId = $testDefFile.BaseName - $id = $baseId + "-Test$count" - $t = [PSCustomObject]@{} - $t | Add-Member -MemberType NoteProperty -Name 'Test' -Value $id - $t | Add-Member -MemberType NoteProperty -Name 'Description' -Value $testConfig.Description - $t | Add-Member -MemberType NoteProperty -Name 'Filename' -Value $testConfig.Filename - $t | Add-Member -MemberType NoteProperty -Name 'Parameters' -Value $testConfig.Parameters - $t | Add-Member -MemberType NoteProperty -Name 'Architectures' -Value $testConfig.Architectures - $t | Add-Member -MemberType NoteProperty -Name 'Status' -Value $testConfig.Status - $t | Add-Member -MemberType NoteProperty -Name 'TestDef' -Value $testDefFile.FullName - $t | Add-Member -MemberType NoteProperty -Name 'Type' -Value $testType - - $tests += $t - $count += 1 + $count++ } } - $tests + return $allTests | Where-Object { + (-not $FilterTestDef -or $_.TestDef -match $FilterTestDef) -and + (-not $FilterDescription -or $_.Description -match $FilterDescription) -and + (-not $FilterFilename -or $_.Filename -match $FilterFilename) -and + (-not $FilterParameters -or $_.Parameters -match $FilterParameters) -and + (-not $IgnoreFilename -or $_.Filename -notmatch $IgnoreFilename) + } } function List-Tests @@ -173,45 +141,45 @@ function Run-TaefTest $tePath = Join-Path $testFolder "te.exe" $dllFile = Join-Path $testFolder $test.Filename - if ($CustomParameters) - { + $teParams = @($dllFile) + + if ($CustomParameters) { $test.Parameters = $CustomParameters } - $additionalParams = "" + if ($test.Parameters) { + $teParams += $test.Parameters.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) + } - if ($LogFile) - { - $additionalParams += " /LogFile $LogFile" + $additionalParams = @() + + if ($LogFile) { + $additionalParams += "/LogFile", $LogFile } - if ($EnableETWLogging) - { - $additionalParams += " /enableEtwLogging" + if ($EnableETWLogging) { + $additionalParams += "/enableEtwLogging" - if ($WprProfile) - { - $additionalParams += " /EtwLogger:WprProfile=$WprProfile" + if ($WprProfile) { + $additionalParams += "/EtwLogger:WprProfile=$WprProfile" } - if ($EtwLoggerSavePoint) - { - $additionalParams += " /EtwLogger:SavePoint=$EtwLoggerSavePoint" + if ($EtwLoggerSavePoint) { + $additionalParams += "/EtwLogger:SavePoint=$EtwLoggerSavePoint" } - if ($EtwLoggerRecordingScope) - { - $additionalParams += " /EtwLogger:RecordingScope=$EtwLoggerRecordingScope" + if ($EtwLoggerRecordingScope) { + $additionalParams += "/EtwLogger:RecordingScope=$EtwLoggerRecordingScope" } - if ($WprProfilePath) - { - $additionalParams += " /EtwLogger:WprProfileFile=$WprProfilePath" + if ($WprProfilePath) { + $additionalParams += "/EtwLogger:WprProfileFile=$WprProfilePath" } } + $allParams = $teParams + $additionalParams - & $tePath $dllFile $test.Parameters $additionalParams + & $tePath @allParams } function Run-Tests From b6a213d9d3e30d930a32ed8b36f1a0b688f42212 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 18:54:35 -0700 Subject: [PATCH 19/37] Fixing colors --- tools/RunTests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 2d2330d805..19ce6dd6ed 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -236,7 +236,7 @@ $scriptParent = Split-Path -parent $PSScriptRoot if ($Build) { Write-Host "" - Write-Host "Building tests" + Write-Host "Building tests" -ForegroundColor Yellow Write-Host "" $testsSourceFolder = Join-Path $scriptParent "test" @@ -246,7 +246,7 @@ if ($Build) } Write-Host "" -Write-Host "Running tests for testdef: $TestDef" -ForegroundColor Yellow +Write-Host "Running tests" -ForegroundColor Yellow Write-Host "" $StartTime = Get-Date From 268fdf6f08d02da758eeca1e11d1ec7ce195fc93 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 21:06:54 -0700 Subject: [PATCH 20/37] Adding documentation and removing unnecessary parameters --- tools/RunTests.ps1 | 117 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 104 insertions(+), 13 deletions(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 19ce6dd6ed..1acc358200 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -1,4 +1,100 @@ <# +.SYNOPSIS + Run WinAppSDK tests with filtering and configuration options + +.DESCRIPTION + The RunTests script discovers and executes tests from .testdef files in the specified directory. + It supports building tests before execution, filtering tests by various criteria, and configuring + test execution parameters including ETW logging and custom parameters. + + The script looks for .testdef files (JSON format) that define test configurations including: + - Test descriptions and filenames + - Supported architectures (x86, x64, arm64) + - Test parameters and execution settings + - Test type (TAEF, Powershell) + - Status (Enabled, Disabled) + + Tests can be filtered by multiple criteria and the script supports both TAEF and PowerShell test types. + When building is enabled, the script will compile test projects before execution. + +.PARAMETER Output + The output directory containing built test binaries. Defaults to "BuildOutput". + +.PARAMETER Platform + Target platform architecture for test execution. Valid values: x86, x64, arm64. + Defaults to the current processor architecture. + +.PARAMETER Configuration + Build configuration for tests. Valid values: Release, Debug. Defaults to "Release". + +.PARAMETER RunDisabled + Switch to enable execution of tests marked as "Disabled" in their testdef files. + +.PARAMETER Build + Switch to build test projects before execution. Requires Visual Studio and MSBuild. + +.PARAMETER FilterTestDef + Filter tests by testdef file path using regex pattern matching. + +.PARAMETER FilterDescription + Filter tests by description field using regex pattern matching. + +.PARAMETER FilterDllFilename + Filter tests by filename using regex pattern matching. + +.PARAMETER FilterParameters + Filter tests by parameters field using regex pattern matching. + +.PARAMETER CustomParameters + Override test parameters for all executed tests. + +.PARAMETER LogFile + Path to log file for TAEF test output. + +.PARAMETER EnableETWLogging + Switch to enable ETW (Event Tracing for Windows) logging during test execution. + +.PARAMETER WprProfile + WPR profile name to use with ETW logging. + +.PARAMETER EtwLoggerSavePoint + ETW logger save point configuration. + +.PARAMETER EtwLoggerRecordingScope + ETW logger recording scope setting. + +.PARAMETER WprProfilePath + Path to custom WPR profile file for ETW logging. + +.EXAMPLE + .\RunTests.ps1 + Run all enabled tests in BuildOutput\Release\x64 with default settings. + +.EXAMPLE + .\RunTests.ps1 -Platform x86 -Configuration Debug + Run tests for x86 architecture in Debug configuration. + +.EXAMPLE + .\RunTests.ps1 -Build -FilterDescription "PackageManager.*Add" + Build test projects and run only tests that match the regex "PackageManager.*Add" in their description. + +.EXAMPLE + .\RunTests.ps1 -FilterDllFilename "Notification" + Run tests with "Notification" in its DLL filename . + +.EXAMPLE + .\RunTests.ps1 -EnableETWLogging -WprProfile "MyProfile.wprp" -LogFile "test.log" + Run tests with ETW logging enabled using custom WPR profile and log file. + +.EXAMPLE + .\RunTests.ps1 -RunDisabled -CustomParameters "/select:@Priority=1" + Run all tests including disabled ones, overriding parameters for TAEF priority selection. + +.NOTES + - Requires Visual Studio with MSBuild for building tests + - TAEF (Test Authoring and Execution Framework) must be available for TAEF tests + - PowerShell test execution is not currently implemented + - AMD64 platform is automatically converted to x64 for compatibility #> param( @@ -18,9 +114,7 @@ param( [string]$FilterDescription, - [string]$FilterFilename, - - [string]$IgnoreFilename, + [string]$FilterDllFilename, [string]$FilterParameters, @@ -30,10 +124,6 @@ param( [switch]$EnableETWLogging = $false, - [switch]$AppendWttLogging = $false, - - [string]$TestMode, - [string]$WprProfile, [string]$EtwLoggerSavePoint, @@ -105,7 +195,7 @@ function Get-Tests [PSCustomObject]@{ Test = "$baseId-Test$count" Description = $testConfig.Description - Filename = $testConfig.Filename + DllFilename = $testConfig.DllFilename Parameters = $testConfig.Parameters Architectures = $testConfig.Architectures Status = $testConfig.Status @@ -120,9 +210,8 @@ function Get-Tests return $allTests | Where-Object { (-not $FilterTestDef -or $_.TestDef -match $FilterTestDef) -and (-not $FilterDescription -or $_.Description -match $FilterDescription) -and - (-not $FilterFilename -or $_.Filename -match $FilterFilename) -and + (-not $FilterDllFilename -or $_.DllFilename -match $FilterDllFilename) -and (-not $FilterParameters -or $_.Parameters -match $FilterParameters) -and - (-not $IgnoreFilename -or $_.Filename -notmatch $IgnoreFilename) } } @@ -130,7 +219,7 @@ function List-Tests { param($tests) - $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 + $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,DllFilename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 } function Run-TaefTest @@ -139,7 +228,7 @@ function Run-TaefTest $testFolder = Split-Path -parent $test.TestDef $tePath = Join-Path $testFolder "te.exe" - $dllFile = Join-Path $testFolder $test.Filename + $dllFile = Join-Path $testFolder $test.DllFilename $teParams = @($dllFile) @@ -154,11 +243,13 @@ function Run-TaefTest $additionalParams = @() if ($LogFile) { - $additionalParams += "/LogFile", $LogFile + $additionalParams += "/LogFile:$LogFile" } if ($EnableETWLogging) { $additionalParams += "/enableEtwLogging" + $additionalParams += "/appendWttLogging" + $additionalParams += "/testMode:ETWLogger" if ($WprProfile) { $additionalParams += "/EtwLogger:WprProfile=$WprProfile" From c0a83cc073663a33cc6b04d3e3209422c71e901e Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Mon, 29 Sep 2025 21:15:10 -0700 Subject: [PATCH 21/37] Small fix on documentation --- tools/RunTests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index 1acc358200..a90d670101 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -34,7 +34,7 @@ Switch to build test projects before execution. Requires Visual Studio and MSBuild. .PARAMETER FilterTestDef - Filter tests by testdef file path using regex pattern matching. + Filter tests by testdef file full name using regex pattern matching. .PARAMETER FilterDescription Filter tests by description field using regex pattern matching. From 4f3da2d35a5a66c5339b0c4f23f6e49e6debc4b2 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Tue, 30 Sep 2025 12:02:42 -0700 Subject: [PATCH 22/37] Adding module for test functions --- tools/RunTests.ps1 | 184 +++++++++++---------------------------------- tools/Tests.psm1 | 135 +++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 141 deletions(-) create mode 100644 tools/Tests.psm1 diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 index a90d670101..2646fc3d09 100644 --- a/tools/RunTests.ps1 +++ b/tools/RunTests.ps1 @@ -176,150 +176,15 @@ function Build-Tests } } -function Get-Tests -{ - param($baseFolder) - - $testDefs = Get-ChildItem -Recurse -Filter "*.testdef" $baseFolder -ErrorAction SilentlyContinue - - $allTests = foreach ($testDefFile in $testDefs) - { - $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json - $count = 0 - - foreach ($testConfig in $testJson.Tests) - { - $baseId = $testDefFile.BaseName - $testType = if ($testConfig.PSObject.Properties['Type']) { $testConfig.Type } else { 'TAEF' } - - [PSCustomObject]@{ - Test = "$baseId-Test$count" - Description = $testConfig.Description - DllFilename = $testConfig.DllFilename - Parameters = $testConfig.Parameters - Architectures = $testConfig.Architectures - Status = $testConfig.Status - TestDef = $testDefFile.FullName - Type = $testType - } - - $count++ - } - } - - return $allTests | Where-Object { - (-not $FilterTestDef -or $_.TestDef -match $FilterTestDef) -and - (-not $FilterDescription -or $_.Description -match $FilterDescription) -and - (-not $FilterDllFilename -or $_.DllFilename -match $FilterDllFilename) -and - (-not $FilterParameters -or $_.Parameters -match $FilterParameters) -and - } -} - -function List-Tests -{ - param($tests) - - $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,DllFilename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 -} - -function Run-TaefTest -{ - param($test) - - $testFolder = Split-Path -parent $test.TestDef - $tePath = Join-Path $testFolder "te.exe" - $dllFile = Join-Path $testFolder $test.DllFilename - - $teParams = @($dllFile) - - if ($CustomParameters) { - $test.Parameters = $CustomParameters - } - - if ($test.Parameters) { - $teParams += $test.Parameters.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) - } - - $additionalParams = @() - - if ($LogFile) { - $additionalParams += "/LogFile:$LogFile" - } - - if ($EnableETWLogging) { - $additionalParams += "/enableEtwLogging" - $additionalParams += "/appendWttLogging" - $additionalParams += "/testMode:ETWLogger" - - if ($WprProfile) { - $additionalParams += "/EtwLogger:WprProfile=$WprProfile" - } - - if ($EtwLoggerSavePoint) { - $additionalParams += "/EtwLogger:SavePoint=$EtwLoggerSavePoint" - } - - if ($EtwLoggerRecordingScope) { - $additionalParams += "/EtwLogger:RecordingScope=$EtwLoggerRecordingScope" - } - - if ($WprProfilePath) { - $additionalParams += "/EtwLogger:WprProfileFile=$WprProfilePath" - } - } - - $allParams = $teParams + $additionalParams - - & $tePath @allParams -} - -function Run-Tests -{ - param($tests) - - foreach ($test in $tests) - { - Write-Host "" - Write-Host "$($test.Filename) - $($test.Description)" - Write-Host "" - - $validPlatform = $test.Architectures.Contains($Platform) - $testEnabled = $test.Status -eq "Enabled" - - if ($validPlatform -and ($testEnabled -or $RunDisabled)) - { - Write-Host "Running test for platform $Platform..." - if ($test.Type -eq 'TAEF') - { - Run-TaefTest $test - } - elseif ($test.Type -eq 'Powershell') - { - Write-Host "Powershell tests not supported." - Exit 1 - } - else - { - Write-Host "Unknown test type '$($test.Type)'. Not running." - Exit 1 - } - } - elseif (-not($validPlatform)) - { - Write-Host "$Platform not listed in supported architectures: $($test.Architectures -join ', ')" - } - elseif (-not($testEnabled)) - { - Write-Host "Test is disabled. Not running." - } - } -} - if ($Platform -eq "AMD64") { $Platform = "x64" } +# Import the module containing the functions: +# List-Tests, Get-Tests, Run-Tests +Import-Module "$PSScriptRoot\Tests.psm1" + Write-Host "Configuration: $Configuration, Platform: $Platform" $scriptParent = Split-Path -parent $PSScriptRoot @@ -345,9 +210,46 @@ $StartTime = Get-Date $configPlat = Join-Path $Configuration $Platform $outputFolder = Join-Path $scriptParent $Output $configPlat -$tests = Get-Tests $outputFolder +$tests = Get-Tests $outputFolder | Where-Object { + (-not $FilterTestDef -or $_.TestDef -match $FilterTestDef) -and + (-not $FilterDescription -or $_.Description -match $FilterDescription) -and + (-not $FilterDllFilename -or $_.Filename -match $FilterDllFilename) -and + (-not $FilterParameters -or $_.Parameters -match $FilterParameters) + } + List-Tests $tests -Run-Tests $tests + +$additionalParams = @() + +if ($LogFile) { + $additionalParams += "/LogFile:$LogFile" +} + +if ($EnableETWLogging) { + $additionalParams += "/enableEtwLogging" + $additionalParams += "/appendWttLogging" + $additionalParams += "/testMode:ETWLogger" + + if ($WprProfile) { + $additionalParams += "/EtwLogger:WprProfile=$WprProfile" + } + + if ($EtwLoggerSavePoint) { + $additionalParams += "/EtwLogger:SavePoint=$EtwLoggerSavePoint" + } + + if ($EtwLoggerRecordingScope) { + $additionalParams += "/EtwLogger:RecordingScope=$EtwLoggerRecordingScope" + } + + if ($WprProfilePath) { + $additionalParams += "/EtwLogger:WprProfileFile=$WprProfilePath" + } +} + +Write-Host "Additional parameters for all tests: $($additionalParams -join ' ')" + +Run-Tests -tests $tests -platform $Platform -runDisabled:$RunDisabled -customParameters $CustomParameters -additionalParams $additionalParams $TotalTime = (Get-Date)-$StartTime $TotalMinutes = $TotalTime.Minutes diff --git a/tools/Tests.psm1 b/tools/Tests.psm1 new file mode 100644 index 0000000000..843a1b4188 --- /dev/null +++ b/tools/Tests.psm1 @@ -0,0 +1,135 @@ +class TestInfo +{ + [string]$Test + [string]$Description + [ValidateSet("TAEF", "Powershell", IgnoreCase=$true)] + [string]$Type + [ValidateNotNullOrEmpty()][string]$Filename + [string]$Parameters + [string[]]$Architectures + [string]$Status + [ValidateNotNullOrEmpty()][string]$TestDef +} + +function List-Tests +{ + param([TestInfo[]]$tests) + + $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 +} + +function Get-Tests +{ + param([string]$baseFolder) + + $testDefs = Get-ChildItem -Recurse -Filter "*.testdef" $baseFolder -ErrorAction SilentlyContinue + + $allTests = foreach ($testDefFile in $testDefs) + { + $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json + $count = 0 + + foreach ($testConfig in $testJson.Tests) + { + $baseId = $testDefFile.BaseName + $testType = if ($testConfig.PSObject.Properties['Type']) { $testConfig.Type } else { 'TAEF' } + + [TestInfo]@{ + Test = "$baseId-Test$count" + Description = $testConfig.Description + Filename = $testConfig.Filename + Parameters = $testConfig.Parameters + Architectures = $testConfig.Architectures + Status = $testConfig.Status + TestDef = $testDefFile.FullName + Type = $testType + } + + $count++ + } + } + + return $allTests +} + +function Run-TaefTest +{ + param( + [TestInfo]$test, + [string]$customParameters = "", + [string]$additionalParams = "" + ) + + $testFolder = Split-Path -parent $test.TestDef + $tePath = Join-Path $testFolder "te.exe" + $dllFile = Join-Path $testFolder $test.Filename + + $teParams = @($dllFile) + + if ($customParameters) { + $test.Parameters = $customParameters + } + + if ($test.Parameters) { + $teParams += $test.Parameters.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) + } + + $allParams = $teParams + $additionalParams.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) + + & $tePath @allParams +} + +function Run-Tests +{ + param( + [TestInfo[]]$tests, + [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] + [string]$platform, + [switch]$runDisabled = $false, + [string]$customParameters = "", + [string]$additionalParams = "" + ) + + Write-Host "Run disabled tests: $runDisabled" + Write-Host "Custom parameters: $customParameters" + Write-Host "Additional parameters: $additionalParams" + + + foreach ($test in $tests) + { + Write-Host "" + Write-Host "$($test.Filename) - $($test.Description)" + Write-Host "" + + $validPlatform = $test.Architectures.Contains($platform) + $testEnabled = $test.Status -eq "Enabled" + + if ($validPlatform -and ($testEnabled -or $runDisabled)) + { + Write-Host "Running test for platform $platform..." + if ($test.Type -eq 'TAEF') + { + Run-TaefTest $test $customParameters $additionalParams + } + elseif ($test.Type -eq 'Powershell') + { + Write-Host "Powershell tests not supported." + Exit 1 + } + else + { + Write-Host "Unknown test type '$($test.Type)'. Not running." + Exit 1 + } + } + elseif (-not($validPlatform)) + { + Write-Host "$Platform not listed in supported architectures: $($test.Architectures -join ', ')" + } + elseif (-not($testEnabled)) + { + Write-Host "Test is disabled. Not running." + } + } +} + From 5ab53e34a00694850cc091af6930f18acd5b5890 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Tue, 30 Sep 2025 12:11:02 -0700 Subject: [PATCH 23/37] Changing TestAll.ps1 to use Tests.psm1 module --- TestAll.ps1 | 138 +++++++++------------------------------------------- 1 file changed, 22 insertions(+), 116 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index 016afd2b4c..02197982ca 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -83,120 +83,6 @@ $lastexitcode = 0 Set-StrictMode -Version 3.0 $ErrorActionPreference = 'Stop' -function Get-Tests -{ - $configPlat = Join-Path $Configuration $Platform - $outputFolderPath = Join-Path $OutputFolder $configPlat - - $tests = @() - foreach ($testdef in (Get-ChildItem -Recurse -Filter "*.testdef" $outputFolderPath)) - { - $testJson = Get-Content -Raw $testdef.FullName | ConvertFrom-Json - - $count = 0 - $baseId = $testdef.BaseName - foreach ($testConfig in $testJson.Tests) - { - $testConfig | Write-Host - if ($testConfig -contains 'Type') - { - $testType = $testConfig.Type - } - else - { - $testType = 'TAEF' - } - - $id = $baseId + "-Test$count" - $t = [PSCustomObject]@{} - $t | Add-Member -MemberType NoteProperty -Name 'Test' -Value $id - $t | Add-Member -MemberType NoteProperty -Name 'Description' -Value $testConfig.Description - $t | Add-Member -MemberType NoteProperty -Name 'Filename' -Value $testConfig.Filename - $t | Add-Member -MemberType NoteProperty -Name 'Parameters' -Value $testConfig.Parameters - $t | Add-Member -MemberType NoteProperty -Name 'Architectures' -Value $testConfig.Architectures - $t | Add-Member -MemberType NoteProperty -Name 'Status' -Value $testConfig.Status - $t | Add-Member -MemberType NoteProperty -Name 'TestDef' -Value $testdef.FullName - $t | Add-Member -MemberType NoteProperty -Name 'Type' -Value $testType - - $tests += $t - $count += 1 - } - } - - if ($callingStage -eq 'TestSampleApps') - { - $tests = $tests | Where-Object { $_.Filename -like "WindowsAppSDK.Test.SampleTests.dll" } - } - else - { - $tests = $tests | Where-Object { $_.Filename -notlike "WindowsAppSDK.Test.SampleTests.dll" } - } - - $tests -} - -function List-Tests -{ - $tests = Get-Tests - $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 -} - -function Run-TaefTest -{ - param($test) - - $testFolder = Split-Path -parent $test.TestDef - $tePath = Join-Path $testFolder "te.exe" - $dllFile = Join-Path $testFolder $test.Filename - - $teLogFile = (Join-Path $env:Build_SourcesDirectory "BuildOutput\$Configuration\$Platform\Te.wtl") - $teLogPathTo = (Join-Path $env:Build_SourcesDirectory "TestOutput\$Configuration\$Platform") - - & $tePath $dllFile $test.Parameters /enableWttLogging /appendWttLogging /screenCaptureOnError /logFile:$teLogFile /testMode:EtwLogger /EtwLogger:WprProfile=WDGDEPAdex /EtwLogger:SavePoint=TestFailure /EtwLogger:RecordingScope=Execution /EtwLogger:WprProfileFile=$wprProfilePath -} - -function Run-PowershellTest -{ - param($test) - - Write-Host "Powershell tests not supported" -} - -function Run-Tests -{ - $tests = Get-Tests - foreach ($test in $tests) - { - Write-Host "$($test.Filename) - $($test.Description)" - $validPlatform = $test.Architectures.Contains($Platform) - $testEnabled = $test.Status -eq "Enabled" - if ($validPlatform -and $testEnabled) - { - if ($test.Type -eq 'TAEF') - { - Run-TaefTest $test - } - elseif ($test.Type -eq 'Powershell') - { - Run-PowershellTest $test - } - else - { - Write-Host "Unknown test type '$test.Type'. Not running." - Exit 1 - } - } - elseif (-not($validPlatform)) - { - Write-Host "$Platform not listed in supported architectures." - } - elseif (-not($testEnabled)) - { - Write-Host "Test is disabled. Not running." - } - } -} - function Get-SystemInfo { $regkey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' @@ -233,14 +119,32 @@ function Get-SystemInfo $env:Build_Platform = $Platform.ToLower() $env:Build_Configuration = $Configuration.ToLower() +# Import the module containing the functions: +# List-Tests, Get-Tests, Run-Tests +Import-Module "$PSScriptRoot\tools\Tests.psm1" + if ($ShowSystemInfo -eq $true) { Get-SystemInfo } +$configPlat = Join-Path $Configuration $Platform +$outputFolderPath = Join-Path $OutputFolder $configPlat + +$allTests = Get-Tests outputFolderPath + +if ($callingStage -eq 'TestSampleApps') +{ + $allTests = $allTests | Where-Object { $_.Filename -like "WindowsAppSDK.Test.SampleTests.dll" } +} +else +{ + $allTests = $allTests | Where-Object { $_.Filename -notlike "WindowsAppSDK.Test.SampleTests.dll" } +} + if ($List -eq $true) { - List-Tests | Out-String + List-Tests $allTests | Out-String } if ($Test -eq $true) @@ -250,7 +154,9 @@ if ($Test -eq $true) remove-item -Path $teLogFile -ErrorAction Ignore remove-item -Path (Join-path $teLogPathTo "Te.wtl") -ErrorAction Ignore - Run-Tests + $additionalParams = "/enableWttLogging /appendWttLogging /screenCaptureOnError /logFile:$teLogFile /testMode:EtwLogger /EtwLogger:WprProfile=WDGDEPAdex /EtwLogger:SavePoint=TestFailure /EtwLogger:RecordingScope=Execution /EtwLogger:WprProfileFile=$wprProfilePath" + + Run-Tests $allTests -additionalParams $additionalParams -platform $Platform.ToLower() # copy test log to TestOutput folder if (Test-Path -Path $teLogFile) { From 21837df36d00c8a921cbe078ea625311efb38e0a Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Tue, 30 Sep 2025 13:22:29 -0700 Subject: [PATCH 24/37] Fixing output path --- TestAll.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index 02197982ca..d2a89a888a 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -131,7 +131,7 @@ if ($ShowSystemInfo -eq $true) $configPlat = Join-Path $Configuration $Platform $outputFolderPath = Join-Path $OutputFolder $configPlat -$allTests = Get-Tests outputFolderPath +$allTests = Get-Tests $outputFolderPath if ($callingStage -eq 'TestSampleApps') { From c50904e79397d571633166f487a1bbe952314545 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Thu, 2 Oct 2025 13:44:33 -0700 Subject: [PATCH 25/37] Unifyting everything in testall.ps1 --- TestAll.ps1 | 218 +++++++++++++----- .../WindowsAppSDK-RunTests-Steps.yml | 6 +- tools/Tests.psm1 | 43 ++++ 3 files changed, 209 insertions(+), 58 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index d2a89a888a..660cf82896 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -36,9 +36,12 @@ ] } -.PARAMETER OutputFolder +.PARAMETER BuildOutputFolder Set the base folder for the script to look for testdefs +.PARAMETER TestOutputFolder + If set, the test log and screenshots will be copied to this folder after running the tests + .PARAMETER Platform Only run tests for the selected platform @@ -48,19 +51,55 @@ .PARAMETER List List the tests available in BuildOutput with their settings +.PARAMETER BuildTests + Builds the tests from source before running them + .PARAMETER Test Runs the tests available in BuildOutput + +.PARAMETER ShowSystemInfo + Show system information before running the tests + +.PARAMETER wprProfilePath + WPR profile to use for ETW logging + +.PARAMETER callingStage + If set to 'TestSampleApps', only tests from WindowsAppSDK.Test.SampleTests.dll + +.PARAMETER CustomParameters + Override test parameters for all executed tests + +.PARAMETER FilterTestDef + Filter tests by testdef file full name using regex pattern matching + +.PARAMETER FilterDescription + Filter tests by description field using regex pattern matching + +.PARAMETER FilterDllFilename + Filter tests by Dll filename using regex pattern matching + +.PARAMETER FilterParameters + Filter tests by parameters field using regex pattern matching + #> +# Import the module containing the functions: +# List-Tests, Get-Tests, Run-Tests, Build-Tests +# And the class TestInfo +using module .\tools\Tests.psm1 + param( - [Parameter(Mandatory=$true)] - [string]$OutputFolder, + [Parameter(Mandatory=$false)] + [string]$BuildOutputFolder = (Join-Path $PSScriptRoot "BuildOutput"), - [Parameter(Mandatory=$true)] - [string]$Platform, + [Parameter(Mandatory=$false)] + [string]$TestOutputFolder = "", - [Parameter(Mandatory=$true)] - [string]$Configuration, + [Parameter(Mandatory=$false)] + [string]$Platform = "$($env:PROCESSOR_ARCHITECTURE)", + + [Parameter(Mandatory=$false)] + [string]$Configuration = "Release", [Parameter(Mandatory=$false)] [Switch]$Test, @@ -69,15 +108,35 @@ param( [Switch]$List, [Parameter(Mandatory=$false)] - [Switch]$ShowSystemInfo=$true, + [Switch]$BuildTests, - [Parameter(Mandatory=$true)] + [Parameter(Mandatory=$false)] + [Switch]$ShowSystemInfo = $true, + + [switch]$SaveScreenshots, + + [Parameter(Mandatory=$false)] [string]$wprProfilePath, [Parameter(Mandatory=$false)] - [string]$callingStage = '' + [string]$callingStage, + + [string]$CustomParameters = "", + + [string]$FilterTestDef = "", + + [string]$FilterDescription = "", + + [string]$FilterDllFilename = "", + + [string]$FilterParameters = "" ) +if ($Platform -eq "AMD64") +{ + $Platform = "x64" +} + $StartTime = Get-Date $lastexitcode = 0 Set-StrictMode -Version 3.0 @@ -116,32 +175,58 @@ function Get-SystemInfo Write-Host "Powershell : $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)" } +function FilterTests +{ + param( + [TestInfo[]]$tests + ) + + $filteredTests = $tests | Where-Object { + (-not $FilterTestDef -or $_.TestDef -match $FilterTestDef) -and + (-not $FilterDescription -or $_.Description -match $FilterDescription) -and + (-not $FilterDllFilename -or $_.Filename -match $FilterDllFilename) -and + (-not $FilterParameters -or $_.Parameters -match $FilterParameters) + } + + if ($callingStage -eq 'TestSampleApps') + { + $filteredTests = $filteredTests | Where-Object { $_.Filename -like "WindowsAppSDK.Test.SampleTests.dll" } + } + else + { + $filteredTests = $filteredTests | Where-Object { $_.Filename -notlike "WindowsAppSDK.Test.SampleTests.dll" } + } + + return $filteredTests +} + $env:Build_Platform = $Platform.ToLower() $env:Build_Configuration = $Configuration.ToLower() -# Import the module containing the functions: -# List-Tests, Get-Tests, Run-Tests -Import-Module "$PSScriptRoot\tools\Tests.psm1" - if ($ShowSystemInfo -eq $true) { Get-SystemInfo } -$configPlat = Join-Path $Configuration $Platform -$outputFolderPath = Join-Path $OutputFolder $configPlat +if ($BuildTests) +{ + Write-Host "" + Write-Host "Building tests" -ForegroundColor Yellow + Write-Host "" -$allTests = Get-Tests $outputFolderPath + $testsSourceFolder = Join-Path $PSScriptRoot "test" -if ($callingStage -eq 'TestSampleApps') -{ - $allTests = $allTests | Where-Object { $_.Filename -like "WindowsAppSDK.Test.SampleTests.dll" } -} -else -{ - $allTests = $allTests | Where-Object { $_.Filename -notlike "WindowsAppSDK.Test.SampleTests.dll" } + $tests = Get-Tests $testsSourceFolder + $tests = FilterTests $tests + Build-Tests $tests # TODO: pass platform/config } +$configPlat = Join-Path $Configuration $Platform +$outputFolderPath = Join-Path $BuildOutputFolder $configPlat + +$allTests = Get-Tests $outputFolderPath +$allTests = FilterTests $allTests + if ($List -eq $true) { List-Tests $allTests | Out-String @@ -149,50 +234,71 @@ if ($List -eq $true) if ($Test -eq $true) { - $teLogFile = (Join-Path $env:Build_SourcesDirectory "BuildOutput\$Configuration\$Platform\Te.wtl") - $teLogPathTo = (Join-Path $env:Build_SourcesDirectory "TestOutput\$Configuration\$Platform") + $additionalParams = @() + + $teLogFile = Join-Path $BuildOutputFolder "$Configuration\$Platform\Te.wtl" remove-item -Path $teLogFile -ErrorAction Ignore - remove-item -Path (Join-path $teLogPathTo "Te.wtl") -ErrorAction Ignore + $additionalParams += "/logFile:$teLogFile" - $additionalParams = "/enableWttLogging /appendWttLogging /screenCaptureOnError /logFile:$teLogFile /testMode:EtwLogger /EtwLogger:WprProfile=WDGDEPAdex /EtwLogger:SavePoint=TestFailure /EtwLogger:RecordingScope=Execution /EtwLogger:WprProfileFile=$wprProfilePath" + if ($wprProfilePath -ne '') + { + $additionalParams += "/enableEtwLogging" + $additionalParams += "/appendWttLogging" + $additionalParams += "/testMode:ETWLogger" + $additionalParams += "/EtwLogger:WprProfile=WDGDEPAdex" + $additionalParams += "/EtwLogger:SavePoint=TestFailure" + $additionalParams += "/EtwLogger:RecordingScope=Execution" + $additionalParams += "/EtwLogger:WprProfileFile=$WprProfilePath" + } - Run-Tests $allTests -additionalParams $additionalParams -platform $Platform.ToLower() + if ($SaveScreenshots) + { + $additionalParams += "/screenCaptureOnError" + } - # copy test log to TestOutput folder - if (Test-Path -Path $teLogFile) { - Write-Host "Starting copy test log from '$teLogFile'" + Run-Tests $allTests -additionalParams $additionalParams -customParameters $CustomParameters -platform $Platform.ToLower() - New-Item -ItemType Directory -Path $teLogPathTo -Force - copy-item -Path $teLogFile -Destination $teLogPathTo -Force + if ($TestOutputFolder -ne '') + { + $teLogPathTo = Join-Path $TestOutputFolder "$Configuration\$Platform" + remove-item -Path (Join-path $teLogPathTo "Te.wtl") -ErrorAction Ignore - Write-Host "Test log copied to '$teLogPathTo'" - } + # copy test log to TestOutput folder + if (Test-Path -Path $teLogFile) { + Write-Host "Starting copy test log from '$teLogFile'" - # copy screenshots to TestOutput folder - $screenshotsFolder = Join-Path $env:Build_SourcesDirectory "WexLogFileOutput" - if (Test-Path -Path $screenshotsFolder) { - Write-Host "Starting copy screenshots from '$screenshotsFolder'" + New-Item -ItemType Directory -Path $teLogPathTo -Force + copy-item -Path $teLogFile -Destination $teLogPathTo -Force - # Copy at most 50 screenshots to the upload path. - # In the cases where a large number of tests failed, there is little value in uploading dozens of screenshots - $files = Get-ChildItem -Path $screenshotsFolder -Filter *.jpg |Select-Object -First 50 - foreach($file in $files) - { - Copy-Item $file.FullName $teLogPathTo -Force + Write-Host "Test log copied to '$teLogPathTo'" } - # Copy at most 20 tracelogging files to the upload path. - $files = Get-ChildItem -Path $screenshotsFolder -Filter *.etl |Select-Object -First 20 - foreach($file in $files) + # copy screenshots to TestOutput folder + $screenshotsFolder = Join-Path (Split-Path $BuildOutpurFolder -parent) "WexLogFileOutput" + if (Test-Path -Path $screenshotsFolder) { + Write-Host "Starting copy screenshots from '$screenshotsFolder'" + + # Copy at most 50 screenshots to the upload path. + # In the cases where a large number of tests failed, there is little value in uploading dozens of screenshots + $files = Get-ChildItem -Path $screenshotsFolder -Filter *.jpg |Select-Object -First 50 + foreach($file in $files) + { + Copy-Item $file.FullName $teLogPathTo -Force + } + + # Copy at most 20 tracelogging files to the upload path. + $files = Get-ChildItem -Path $screenshotsFolder -Filter *.etl |Select-Object -First 20 + foreach($file in $files) + { + Copy-Item $file.FullName $teLogPathTo -Force + } + + Write-Host "Test results copied to '$teLogPathTo'" + } + else { - Copy-Item $file.FullName $teLogPathTo -Force + Write-Host "WexLogFileOutput not found" } - - Write-Host "Test results copied to '$teLogPathTo'" - } - else - { - Write-Host "WexLogFileOutput not found" } } diff --git a/build/AzurePipelinesTemplates/WindowsAppSDK-RunTests-Steps.yml b/build/AzurePipelinesTemplates/WindowsAppSDK-RunTests-Steps.yml index 573fe1c796..fb73eba9aa 100644 --- a/build/AzurePipelinesTemplates/WindowsAppSDK-RunTests-Steps.yml +++ b/build/AzurePipelinesTemplates/WindowsAppSDK-RunTests-Steps.yml @@ -231,17 +231,19 @@ steps: SourceFolder: '$(Build.SourcesDirectory)\BuildOutput\$(buildConfiguration)\$(buildPlatform)\WindowsAppSDK.Test.NetCore\net6' TargetFolder: '$(Build.SourcesDirectory)\BuildOutput\$(buildConfiguration)\$(buildPlatform)\WindowsAppSDK.Test.SampleTests\net6' Contents: '**' - + - task: PowerShell@2 displayName: 'Run TAEF Tests' inputs: filePath: 'TestAll.ps1' arguments: > - -OutputFolder "$(Build.SourcesDirectory)\BuildOutput" + -BuildOutputFolder "$(Build.SourcesDirectory)\BuildOutput" + -TestOutputFolder "$(Build.SourcesDirectory)\TestOutput" -Platform "${{ parameters.buildPlatform }}" -Configuration "${{ parameters.buildConfiguration }}" -Test -List + -SaveScreenshots -wprProfilePath "$(Build.SourcesDirectory)\WindowsAppSDKConfig\src\test\AppModelProviders.wprp" -callingStage "${{ parameters.callingStage }}" diff --git a/tools/Tests.psm1 b/tools/Tests.psm1 index 843a1b4188..7d50f38c10 100644 --- a/tools/Tests.psm1 +++ b/tools/Tests.psm1 @@ -52,6 +52,49 @@ function Get-Tests return $allTests } +function Build-Tests +{ + param( + [TestInfo[]]$tests + ) + + $VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath + Write-Host "VCToolsInstallDir: $VCToolsInstallDir" + + $msbuildPath = Join-Path $VCToolsInstallDir "MSBuild\Current\Bin\msbuild.exe" + Write-Host "MSBuild Path: $msbuildPath" + + # Build each test project once + $projectsBuilt = @{} + + foreach ($test in $tests) + { + $testDefFile = $test.TestDef + Write-Host "Building tests for testdef: $testDefFile" + + $testFolder = Split-Path -parent $testDefFile + Write-Host "Building tests in folder: $testFolder" + $projFile = Get-ChildItem -Filter "*.vcxproj" -Path $testFolder | Select-Object -First 1 + + if ($null -eq $projFile) + { + Write-Error "Could not find a .vcxproj file in $testFolder" + Exit 1 + } + + Write-Host "Found project file: $projFile" + + if ($projectsBuilt.ContainsKey($projFile.FullName)) + { + Write-Host "Project already built. Skipping." + continue + } + + & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform /v:minimal + $projectsBuilt[$projFile.FullName] = $true + } +} + function Run-TaefTest { param( From c9e41839189f6da721dcf397b846ac3011963078 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Thu, 2 Oct 2025 14:31:25 -0700 Subject: [PATCH 26/37] Removing run tests scripts --- tools/RunTests.cmd | 5 - tools/RunTests.ps1 | 258 --------------------------------------------- 2 files changed, 263 deletions(-) delete mode 100644 tools/RunTests.cmd delete mode 100644 tools/RunTests.ps1 diff --git a/tools/RunTests.cmd b/tools/RunTests.cmd deleted file mode 100644 index de5add0d2a..0000000000 --- a/tools/RunTests.cmd +++ /dev/null @@ -1,5 +0,0 @@ -@echo off - -powershell -ExecutionPolicy Unrestricted -NoLogo -NoProfile -File %~dp0\tools\RunTests.ps1 %* - -exit /b %ERRORLEVEL% diff --git a/tools/RunTests.ps1 b/tools/RunTests.ps1 deleted file mode 100644 index 2646fc3d09..0000000000 --- a/tools/RunTests.ps1 +++ /dev/null @@ -1,258 +0,0 @@ -<# -.SYNOPSIS - Run WinAppSDK tests with filtering and configuration options - -.DESCRIPTION - The RunTests script discovers and executes tests from .testdef files in the specified directory. - It supports building tests before execution, filtering tests by various criteria, and configuring - test execution parameters including ETW logging and custom parameters. - - The script looks for .testdef files (JSON format) that define test configurations including: - - Test descriptions and filenames - - Supported architectures (x86, x64, arm64) - - Test parameters and execution settings - - Test type (TAEF, Powershell) - - Status (Enabled, Disabled) - - Tests can be filtered by multiple criteria and the script supports both TAEF and PowerShell test types. - When building is enabled, the script will compile test projects before execution. - -.PARAMETER Output - The output directory containing built test binaries. Defaults to "BuildOutput". - -.PARAMETER Platform - Target platform architecture for test execution. Valid values: x86, x64, arm64. - Defaults to the current processor architecture. - -.PARAMETER Configuration - Build configuration for tests. Valid values: Release, Debug. Defaults to "Release". - -.PARAMETER RunDisabled - Switch to enable execution of tests marked as "Disabled" in their testdef files. - -.PARAMETER Build - Switch to build test projects before execution. Requires Visual Studio and MSBuild. - -.PARAMETER FilterTestDef - Filter tests by testdef file full name using regex pattern matching. - -.PARAMETER FilterDescription - Filter tests by description field using regex pattern matching. - -.PARAMETER FilterDllFilename - Filter tests by filename using regex pattern matching. - -.PARAMETER FilterParameters - Filter tests by parameters field using regex pattern matching. - -.PARAMETER CustomParameters - Override test parameters for all executed tests. - -.PARAMETER LogFile - Path to log file for TAEF test output. - -.PARAMETER EnableETWLogging - Switch to enable ETW (Event Tracing for Windows) logging during test execution. - -.PARAMETER WprProfile - WPR profile name to use with ETW logging. - -.PARAMETER EtwLoggerSavePoint - ETW logger save point configuration. - -.PARAMETER EtwLoggerRecordingScope - ETW logger recording scope setting. - -.PARAMETER WprProfilePath - Path to custom WPR profile file for ETW logging. - -.EXAMPLE - .\RunTests.ps1 - Run all enabled tests in BuildOutput\Release\x64 with default settings. - -.EXAMPLE - .\RunTests.ps1 -Platform x86 -Configuration Debug - Run tests for x86 architecture in Debug configuration. - -.EXAMPLE - .\RunTests.ps1 -Build -FilterDescription "PackageManager.*Add" - Build test projects and run only tests that match the regex "PackageManager.*Add" in their description. - -.EXAMPLE - .\RunTests.ps1 -FilterDllFilename "Notification" - Run tests with "Notification" in its DLL filename . - -.EXAMPLE - .\RunTests.ps1 -EnableETWLogging -WprProfile "MyProfile.wprp" -LogFile "test.log" - Run tests with ETW logging enabled using custom WPR profile and log file. - -.EXAMPLE - .\RunTests.ps1 -RunDisabled -CustomParameters "/select:@Priority=1" - Run all tests including disabled ones, overriding parameters for TAEF priority selection. - -.NOTES - - Requires Visual Studio with MSBuild for building tests - - TAEF (Test Authoring and Execution Framework) must be available for TAEF tests - - PowerShell test execution is not currently implemented - - AMD64 platform is automatically converted to x64 for compatibility -#> - -param( - [string]$Output = "BuildOutput", - - [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] - [string]$Platform = "$($env:PROCESSOR_ARCHITECTURE)", - - [ValidateSet("Release", "Debug", IgnoreCase=$true)] - [string]$Configuration = "Release", - - [switch]$RunDisabled = $false, - - [switch]$Build = $false, - - [string]$FilterTestDef, - - [string]$FilterDescription, - - [string]$FilterDllFilename, - - [string]$FilterParameters, - - [string]$CustomParameters, - - [string]$LogFile, - - [switch]$EnableETWLogging = $false, - - [string]$WprProfile, - - [string]$EtwLoggerSavePoint, - - [string]$EtwLoggerRecordingScope, - - [string]$WprProfilePath -) - -function Build-Tests -{ - param( - $tests - ) - - $VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath - Write-Host "VCToolsInstallDir: $VCToolsInstallDir" - - $msbuildPath = Join-Path $VCToolsInstallDir "MSBuild\Current\Bin\msbuild.exe" - Write-Host "MSBuild Path: $msbuildPath" - - # Build each test project once - $projectsBuilt = @{} - - foreach ($test in $tests) - { - $testDefFile = $test.TestDef - Write-Host "Building tests for testdef: $testDefFile" - - $testFolder = Split-Path -parent $testDefFile - Write-Host "Building tests in folder: $testFolder" - $projFile = Get-ChildItem -Filter "*.vcxproj" -Path $testFolder | Select-Object -First 1 - - if ($null -eq $projFile) - { - Write-Error "Could not find a .vcxproj file in $testFolder" - Exit 1 - } - - Write-Host "Found project file: $projFile" - - if ($projectsBuilt.ContainsKey($projFile.FullName)) - { - Write-Host "Project already built. Skipping." - continue - } - - & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform /v:minimal - $projectsBuilt[$projFile.FullName] = $true - } -} - -if ($Platform -eq "AMD64") -{ - $Platform = "x64" -} - -# Import the module containing the functions: -# List-Tests, Get-Tests, Run-Tests -Import-Module "$PSScriptRoot\Tests.psm1" - -Write-Host "Configuration: $Configuration, Platform: $Platform" - -$scriptParent = Split-Path -parent $PSScriptRoot - -if ($Build) -{ - Write-Host "" - Write-Host "Building tests" -ForegroundColor Yellow - Write-Host "" - - $testsSourceFolder = Join-Path $scriptParent "test" - - $tests = Get-Tests $testsSourceFolder - Build-Tests $tests -} - -Write-Host "" -Write-Host "Running tests" -ForegroundColor Yellow -Write-Host "" - -$StartTime = Get-Date - -$configPlat = Join-Path $Configuration $Platform -$outputFolder = Join-Path $scriptParent $Output $configPlat - -$tests = Get-Tests $outputFolder | Where-Object { - (-not $FilterTestDef -or $_.TestDef -match $FilterTestDef) -and - (-not $FilterDescription -or $_.Description -match $FilterDescription) -and - (-not $FilterDllFilename -or $_.Filename -match $FilterDllFilename) -and - (-not $FilterParameters -or $_.Parameters -match $FilterParameters) - } - -List-Tests $tests - -$additionalParams = @() - -if ($LogFile) { - $additionalParams += "/LogFile:$LogFile" -} - -if ($EnableETWLogging) { - $additionalParams += "/enableEtwLogging" - $additionalParams += "/appendWttLogging" - $additionalParams += "/testMode:ETWLogger" - - if ($WprProfile) { - $additionalParams += "/EtwLogger:WprProfile=$WprProfile" - } - - if ($EtwLoggerSavePoint) { - $additionalParams += "/EtwLogger:SavePoint=$EtwLoggerSavePoint" - } - - if ($EtwLoggerRecordingScope) { - $additionalParams += "/EtwLogger:RecordingScope=$EtwLoggerRecordingScope" - } - - if ($WprProfilePath) { - $additionalParams += "/EtwLogger:WprProfileFile=$WprProfilePath" - } -} - -Write-Host "Additional parameters for all tests: $($additionalParams -join ' ')" - -Run-Tests -tests $tests -platform $Platform -runDisabled:$RunDisabled -customParameters $CustomParameters -additionalParams $additionalParams - -$TotalTime = (Get-Date)-$StartTime -$TotalMinutes = $TotalTime.Minutes -$TotalSeconds = $TotalTime.Seconds -Write-Host "" -Write-Host "Total Running Time: $TotalMinutes minutes and $TotalSeconds seconds" From 52d21851d3169605d6ace1a852eb2a5d3577e182 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Thu, 2 Oct 2025 14:47:18 -0700 Subject: [PATCH 27/37] Fix typo --- TestAll.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index 660cf82896..6f7f043b53 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -274,7 +274,7 @@ if ($Test -eq $true) } # copy screenshots to TestOutput folder - $screenshotsFolder = Join-Path (Split-Path $BuildOutpurFolder -parent) "WexLogFileOutput" + $screenshotsFolder = Join-Path (Split-Path $BuildOutputFolder -parent) "WexLogFileOutput" if (Test-Path -Path $screenshotsFolder) { Write-Host "Starting copy screenshots from '$screenshotsFolder'" From ea45810153e37ce998c5634fd87d021a1d5a763d Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Thu, 2 Oct 2025 16:28:04 -0700 Subject: [PATCH 28/37] Adding configuration and platform to build function and parenthesis to paths --- TestAll.ps1 | 6 +++--- tools/Tests.psm1 | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index 6f7f043b53..0863a0daaa 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -218,7 +218,7 @@ if ($BuildTests) $tests = Get-Tests $testsSourceFolder $tests = FilterTests $tests - Build-Tests $tests # TODO: pass platform/config + Build-Tests $tests -Platform $Platform -Configuration $Configuration } $configPlat = Join-Path $Configuration $Platform @@ -236,7 +236,7 @@ if ($Test -eq $true) { $additionalParams = @() - $teLogFile = Join-Path $BuildOutputFolder "$Configuration\$Platform\Te.wtl" + $teLogFile = (Join-Path $BuildOutputFolder "$Configuration\$Platform\Te.wtl") remove-item -Path $teLogFile -ErrorAction Ignore $additionalParams += "/logFile:$teLogFile" @@ -260,7 +260,7 @@ if ($Test -eq $true) if ($TestOutputFolder -ne '') { - $teLogPathTo = Join-Path $TestOutputFolder "$Configuration\$Platform" + $teLogPathTo = (Join-Path $TestOutputFolder "$Configuration\$Platform") remove-item -Path (Join-path $teLogPathTo "Te.wtl") -ErrorAction Ignore # copy test log to TestOutput folder diff --git a/tools/Tests.psm1 b/tools/Tests.psm1 index 7d50f38c10..9755c6b738 100644 --- a/tools/Tests.psm1 +++ b/tools/Tests.psm1 @@ -55,7 +55,11 @@ function Get-Tests function Build-Tests { param( - [TestInfo[]]$tests + [TestInfo[]]$tests, + [ValidateSet("Debug", "Release", IgnoreCase=$true)] + [string]$Configuration, + [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] + [string]$Platform ) $VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath From 3bf63acb81b334b1c4eaf0499aabdc9d3d18106e Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Thu, 2 Oct 2025 16:43:28 -0700 Subject: [PATCH 29/37] Fixing param to Wtt logging --- TestAll.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index 0863a0daaa..35e47e6fa7 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -236,13 +236,13 @@ if ($Test -eq $true) { $additionalParams = @() - $teLogFile = (Join-Path $BuildOutputFolder "$Configuration\$Platform\Te.wtl") + $teLogFile = Join-Path $BuildOutputFolder "$Configuration\$Platform\Te.wtl" remove-item -Path $teLogFile -ErrorAction Ignore $additionalParams += "/logFile:$teLogFile" if ($wprProfilePath -ne '') { - $additionalParams += "/enableEtwLogging" + $additionalParams += "/enableWttLogging" $additionalParams += "/appendWttLogging" $additionalParams += "/testMode:ETWLogger" $additionalParams += "/EtwLogger:WprProfile=WDGDEPAdex" @@ -260,7 +260,7 @@ if ($Test -eq $true) if ($TestOutputFolder -ne '') { - $teLogPathTo = (Join-Path $TestOutputFolder "$Configuration\$Platform") + $teLogPathTo = Join-Path $TestOutputFolder "$Configuration\$Platform" remove-item -Path (Join-path $teLogPathTo "Te.wtl") -ErrorAction Ignore # copy test log to TestOutput folder From 8a5cb3776fb8ca4ffc1607645cfe18016aa69a42 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Thu, 2 Oct 2025 17:00:06 -0700 Subject: [PATCH 30/37] Changing name from filter tests to select tests --- TestAll.ps1 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index 35e47e6fa7..d572602070 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -175,7 +175,7 @@ function Get-SystemInfo Write-Host "Powershell : $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)" } -function FilterTests +function Select-Tests { param( [TestInfo[]]$tests @@ -216,16 +216,14 @@ if ($BuildTests) $testsSourceFolder = Join-Path $PSScriptRoot "test" - $tests = Get-Tests $testsSourceFolder - $tests = FilterTests $tests + $tests = Select-Tests (Get-Tests $testsSourceFolder) Build-Tests $tests -Platform $Platform -Configuration $Configuration } $configPlat = Join-Path $Configuration $Platform $outputFolderPath = Join-Path $BuildOutputFolder $configPlat -$allTests = Get-Tests $outputFolderPath -$allTests = FilterTests $allTests +$allTests = Select-Tests (Get-Tests $outputFolderPath) if ($List -eq $true) { From f34382d11f6077a802c524404cb4a187af87f9c2 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Thu, 2 Oct 2025 17:37:39 -0700 Subject: [PATCH 31/37] Cleaning up the script a bit --- TestAll.ps1 | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index d572602070..c29dd3e537 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -121,15 +121,15 @@ param( [Parameter(Mandatory=$false)] [string]$callingStage, - [string]$CustomParameters = "", + [string]$CustomParameters, - [string]$FilterTestDef = "", + [string]$FilterTestDef, - [string]$FilterDescription = "", + [string]$FilterDescription, - [string]$FilterDllFilename = "", + [string]$FilterDllFilename, - [string]$FilterParameters = "" + [string]$FilterParameters ) if ($Platform -eq "AMD64") @@ -203,7 +203,7 @@ function Select-Tests $env:Build_Platform = $Platform.ToLower() $env:Build_Configuration = $Configuration.ToLower() -if ($ShowSystemInfo -eq $true) +if ($ShowSystemInfo) { Get-SystemInfo } @@ -220,17 +220,16 @@ if ($BuildTests) Build-Tests $tests -Platform $Platform -Configuration $Configuration } -$configPlat = Join-Path $Configuration $Platform -$outputFolderPath = Join-Path $BuildOutputFolder $configPlat +$outputFolderPath = Join-Path $BuildOutputFolder $Configuration $Platform $allTests = Select-Tests (Get-Tests $outputFolderPath) -if ($List -eq $true) +if ($List) { List-Tests $allTests | Out-String } -if ($Test -eq $true) +if ($Test) { $additionalParams = @() From 4050fff5b1f0a88b72a2ffde32f834b449598916 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Fri, 3 Oct 2025 12:49:00 -0700 Subject: [PATCH 32/37] Simplifying parameters --- TestAll.ps1 | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index c29dd3e537..b6852f4836 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -89,36 +89,26 @@ using module .\tools\Tests.psm1 param( - [Parameter(Mandatory=$false)] [string]$BuildOutputFolder = (Join-Path $PSScriptRoot "BuildOutput"), - [Parameter(Mandatory=$false)] - [string]$TestOutputFolder = "", + [string]$TestOutputFolder, - [Parameter(Mandatory=$false)] [string]$Platform = "$($env:PROCESSOR_ARCHITECTURE)", - [Parameter(Mandatory=$false)] [string]$Configuration = "Release", - [Parameter(Mandatory=$false)] [Switch]$Test, - [Parameter(Mandatory=$false)] [Switch]$List, - [Parameter(Mandatory=$false)] [Switch]$BuildTests, - [Parameter(Mandatory=$false)] [Switch]$ShowSystemInfo = $true, [switch]$SaveScreenshots, - [Parameter(Mandatory=$false)] [string]$wprProfilePath, - [Parameter(Mandatory=$false)] [string]$callingStage, [string]$CustomParameters, From 63deae484c48c10d056d62371a8b1974643a35f1 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Fri, 3 Oct 2025 12:52:05 -0700 Subject: [PATCH 33/37] Moving fuctions back to TestAll.ps1 --- TestAll.ps1 | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 182 insertions(+), 5 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index b6852f4836..19053add94 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -83,11 +83,6 @@ #> -# Import the module containing the functions: -# List-Tests, Get-Tests, Run-Tests, Build-Tests -# And the class TestInfo -using module .\tools\Tests.psm1 - param( [string]$BuildOutputFolder = (Join-Path $PSScriptRoot "BuildOutput"), @@ -132,6 +127,188 @@ $lastexitcode = 0 Set-StrictMode -Version 3.0 $ErrorActionPreference = 'Stop' +class TestInfo +{ + [string]$Test + [string]$Description + [ValidateSet("TAEF", "Powershell", IgnoreCase=$true)] + [string]$Type + [ValidateNotNullOrEmpty()][string]$Filename + [string]$Parameters + [string[]]$Architectures + [string]$Status + [ValidateNotNullOrEmpty()][string]$TestDef +} + +function List-Tests +{ + param([TestInfo[]]$tests) + + $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 +} + +function Get-Tests +{ + param([string]$baseFolder) + + $testDefs = Get-ChildItem -Recurse -Filter "*.testdef" $baseFolder -ErrorAction SilentlyContinue + + $allTests = foreach ($testDefFile in $testDefs) + { + $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json + $count = 0 + + foreach ($testConfig in $testJson.Tests) + { + $baseId = $testDefFile.BaseName + $testType = if ($testConfig.PSObject.Properties['Type']) { $testConfig.Type } else { 'TAEF' } + + [TestInfo]@{ + Test = "$baseId-Test$count" + Description = $testConfig.Description + Filename = $testConfig.Filename + Parameters = $testConfig.Parameters + Architectures = $testConfig.Architectures + Status = $testConfig.Status + TestDef = $testDefFile.FullName + Type = $testType + } + + $count++ + } + } + + return $allTests +} + +function Build-Tests +{ + param( + [TestInfo[]]$tests, + [ValidateSet("Debug", "Release", IgnoreCase=$true)] + [string]$Configuration, + [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] + [string]$Platform + ) + + $VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath + Write-Host "VCToolsInstallDir: $VCToolsInstallDir" + + $msbuildPath = Join-Path $VCToolsInstallDir "MSBuild\Current\Bin\msbuild.exe" + Write-Host "MSBuild Path: $msbuildPath" + + # Build each test project once + $projectsBuilt = @{} + + foreach ($test in $tests) + { + $testDefFile = $test.TestDef + Write-Host "Building tests for testdef: $testDefFile" + + $testFolder = Split-Path -parent $testDefFile + Write-Host "Building tests in folder: $testFolder" + $projFile = Get-ChildItem -Filter "*.vcxproj" -Path $testFolder | Select-Object -First 1 + + if ($null -eq $projFile) + { + Write-Error "Could not find a .vcxproj file in $testFolder" + Exit 1 + } + + Write-Host "Found project file: $projFile" + + if ($projectsBuilt.ContainsKey($projFile.FullName)) + { + Write-Host "Project already built. Skipping." + continue + } + + & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform /v:minimal + $projectsBuilt[$projFile.FullName] = $true + } +} + +function Run-TaefTest +{ + param( + [TestInfo]$test, + [string]$customParameters = "", + [string]$additionalParams = "" + ) + + $testFolder = Split-Path -parent $test.TestDef + $tePath = Join-Path $testFolder "te.exe" + $dllFile = Join-Path $testFolder $test.Filename + + $teParams = @($dllFile) + + if ($customParameters) { + $test.Parameters = $customParameters + } + + if ($test.Parameters) { + $teParams += $test.Parameters.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) + } + + $allParams = $teParams + $additionalParams.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) + + & $tePath @allParams +} + +function Run-Tests +{ + param( + [TestInfo[]]$tests, + [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] + [string]$platform, + [switch]$runDisabled = $false, + [string]$customParameters = "", + [string]$additionalParams = "" + ) + + Write-Host "Run disabled tests: $runDisabled" + Write-Host "Custom parameters: $customParameters" + Write-Host "Additional parameters: $additionalParams" + + + foreach ($test in $tests) + { + Write-Host "" + Write-Host "$($test.Filename) - $($test.Description)" + Write-Host "" + + $validPlatform = $test.Architectures.Contains($platform) + $testEnabled = $test.Status -eq "Enabled" + + if ($validPlatform -and ($testEnabled -or $runDisabled)) + { + Write-Host "Running test for platform $platform..." + if ($test.Type -eq 'TAEF') + { + Run-TaefTest $test $customParameters $additionalParams + } + elseif ($test.Type -eq 'Powershell') + { + Write-Host "Powershell tests not supported." + Exit 1 + } + else + { + Write-Host "Unknown test type '$($test.Type)'. Not running." + Exit 1 + } + } + elseif (-not($validPlatform)) + { + Write-Host "$Platform not listed in supported architectures: $($test.Architectures -join ', ')" + } + elseif (-not($testEnabled)) + { + Write-Host "Test is disabled. Not running." + } + } +} + function Get-SystemInfo { $regkey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' From dc75b5c95bf797cbc37ee3b42684e6ef2c7c3431 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Fri, 3 Oct 2025 12:55:46 -0700 Subject: [PATCH 34/37] Preserving original order of functions --- TestAll.ps1 | 83 +++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index 19053add94..8fc86732c3 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -140,47 +140,6 @@ class TestInfo [ValidateNotNullOrEmpty()][string]$TestDef } -function List-Tests -{ - param([TestInfo[]]$tests) - - $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 -} - -function Get-Tests -{ - param([string]$baseFolder) - - $testDefs = Get-ChildItem -Recurse -Filter "*.testdef" $baseFolder -ErrorAction SilentlyContinue - - $allTests = foreach ($testDefFile in $testDefs) - { - $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json - $count = 0 - - foreach ($testConfig in $testJson.Tests) - { - $baseId = $testDefFile.BaseName - $testType = if ($testConfig.PSObject.Properties['Type']) { $testConfig.Type } else { 'TAEF' } - - [TestInfo]@{ - Test = "$baseId-Test$count" - Description = $testConfig.Description - Filename = $testConfig.Filename - Parameters = $testConfig.Parameters - Architectures = $testConfig.Architectures - Status = $testConfig.Status - TestDef = $testDefFile.FullName - Type = $testType - } - - $count++ - } - } - - return $allTests -} - function Build-Tests { param( @@ -228,6 +187,48 @@ function Build-Tests } } + +function Get-Tests +{ + param([string]$baseFolder) + + $testDefs = Get-ChildItem -Recurse -Filter "*.testdef" $baseFolder -ErrorAction SilentlyContinue + + $allTests = foreach ($testDefFile in $testDefs) + { + $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json + $count = 0 + + foreach ($testConfig in $testJson.Tests) + { + $baseId = $testDefFile.BaseName + $testType = if ($testConfig.PSObject.Properties['Type']) { $testConfig.Type } else { 'TAEF' } + + [TestInfo]@{ + Test = "$baseId-Test$count" + Description = $testConfig.Description + Filename = $testConfig.Filename + Parameters = $testConfig.Parameters + Architectures = $testConfig.Architectures + Status = $testConfig.Status + TestDef = $testDefFile.FullName + Type = $testType + } + + $count++ + } + } + + return $allTests +} + +function List-Tests +{ + param([TestInfo[]]$tests) + + $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 +} + function Run-TaefTest { param( From 7c56b3f97dd28371e1fbb80869949e839648a5ce Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Fri, 3 Oct 2025 12:59:40 -0700 Subject: [PATCH 35/37] Removing module file --- tools/Tests.psm1 | 182 ----------------------------------------------- 1 file changed, 182 deletions(-) delete mode 100644 tools/Tests.psm1 diff --git a/tools/Tests.psm1 b/tools/Tests.psm1 deleted file mode 100644 index 9755c6b738..0000000000 --- a/tools/Tests.psm1 +++ /dev/null @@ -1,182 +0,0 @@ -class TestInfo -{ - [string]$Test - [string]$Description - [ValidateSet("TAEF", "Powershell", IgnoreCase=$true)] - [string]$Type - [ValidateNotNullOrEmpty()][string]$Filename - [string]$Parameters - [string[]]$Architectures - [string]$Status - [ValidateNotNullOrEmpty()][string]$TestDef -} - -function List-Tests -{ - param([TestInfo[]]$tests) - - $tests | Sort-Object -Property Test | Format-Table Test,Description,Type,Filename,Parameters,Architectures,Status -AutoSize | Out-String -Width 512 -} - -function Get-Tests -{ - param([string]$baseFolder) - - $testDefs = Get-ChildItem -Recurse -Filter "*.testdef" $baseFolder -ErrorAction SilentlyContinue - - $allTests = foreach ($testDefFile in $testDefs) - { - $testJson = Get-Content -Raw $testDefFile.FullName | ConvertFrom-Json - $count = 0 - - foreach ($testConfig in $testJson.Tests) - { - $baseId = $testDefFile.BaseName - $testType = if ($testConfig.PSObject.Properties['Type']) { $testConfig.Type } else { 'TAEF' } - - [TestInfo]@{ - Test = "$baseId-Test$count" - Description = $testConfig.Description - Filename = $testConfig.Filename - Parameters = $testConfig.Parameters - Architectures = $testConfig.Architectures - Status = $testConfig.Status - TestDef = $testDefFile.FullName - Type = $testType - } - - $count++ - } - } - - return $allTests -} - -function Build-Tests -{ - param( - [TestInfo[]]$tests, - [ValidateSet("Debug", "Release", IgnoreCase=$true)] - [string]$Configuration, - [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] - [string]$Platform - ) - - $VCToolsInstallDir = . "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -property installationPath - Write-Host "VCToolsInstallDir: $VCToolsInstallDir" - - $msbuildPath = Join-Path $VCToolsInstallDir "MSBuild\Current\Bin\msbuild.exe" - Write-Host "MSBuild Path: $msbuildPath" - - # Build each test project once - $projectsBuilt = @{} - - foreach ($test in $tests) - { - $testDefFile = $test.TestDef - Write-Host "Building tests for testdef: $testDefFile" - - $testFolder = Split-Path -parent $testDefFile - Write-Host "Building tests in folder: $testFolder" - $projFile = Get-ChildItem -Filter "*.vcxproj" -Path $testFolder | Select-Object -First 1 - - if ($null -eq $projFile) - { - Write-Error "Could not find a .vcxproj file in $testFolder" - Exit 1 - } - - Write-Host "Found project file: $projFile" - - if ($projectsBuilt.ContainsKey($projFile.FullName)) - { - Write-Host "Project already built. Skipping." - continue - } - - & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform /v:minimal - $projectsBuilt[$projFile.FullName] = $true - } -} - -function Run-TaefTest -{ - param( - [TestInfo]$test, - [string]$customParameters = "", - [string]$additionalParams = "" - ) - - $testFolder = Split-Path -parent $test.TestDef - $tePath = Join-Path $testFolder "te.exe" - $dllFile = Join-Path $testFolder $test.Filename - - $teParams = @($dllFile) - - if ($customParameters) { - $test.Parameters = $customParameters - } - - if ($test.Parameters) { - $teParams += $test.Parameters.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) - } - - $allParams = $teParams + $additionalParams.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries) - - & $tePath @allParams -} - -function Run-Tests -{ - param( - [TestInfo[]]$tests, - [ValidateSet("x86", "x64", "arm64", IgnoreCase=$true)] - [string]$platform, - [switch]$runDisabled = $false, - [string]$customParameters = "", - [string]$additionalParams = "" - ) - - Write-Host "Run disabled tests: $runDisabled" - Write-Host "Custom parameters: $customParameters" - Write-Host "Additional parameters: $additionalParams" - - - foreach ($test in $tests) - { - Write-Host "" - Write-Host "$($test.Filename) - $($test.Description)" - Write-Host "" - - $validPlatform = $test.Architectures.Contains($platform) - $testEnabled = $test.Status -eq "Enabled" - - if ($validPlatform -and ($testEnabled -or $runDisabled)) - { - Write-Host "Running test for platform $platform..." - if ($test.Type -eq 'TAEF') - { - Run-TaefTest $test $customParameters $additionalParams - } - elseif ($test.Type -eq 'Powershell') - { - Write-Host "Powershell tests not supported." - Exit 1 - } - else - { - Write-Host "Unknown test type '$($test.Type)'. Not running." - Exit 1 - } - } - elseif (-not($validPlatform)) - { - Write-Host "$Platform not listed in supported architectures: $($test.Architectures -join ', ')" - } - elseif (-not($testEnabled)) - { - Write-Host "Test is disabled. Not running." - } - } -} - From f5c457dc074d8722a383b538b9477d3317038b5b Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Fri, 3 Oct 2025 13:55:36 -0700 Subject: [PATCH 36/37] Fixing path building --- TestAll.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index 8fc86732c3..fd2c95050c 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -388,7 +388,7 @@ if ($BuildTests) Build-Tests $tests -Platform $Platform -Configuration $Configuration } -$outputFolderPath = Join-Path $BuildOutputFolder $Configuration $Platform +$outputFolderPath = Join-Path $BuildOutputFolder "$Configuration\$Platform" $allTests = Select-Tests (Get-Tests $outputFolderPath) @@ -401,7 +401,7 @@ if ($Test) { $additionalParams = @() - $teLogFile = Join-Path $BuildOutputFolder "$Configuration\$Platform\Te.wtl" + $teLogFile = Join-Path $outputFolderPath "Te.wtl" remove-item -Path $teLogFile -ErrorAction Ignore $additionalParams += "/logFile:$teLogFile" From 06101c6a179c8049e68da5b183cdc440f36dcd33 Mon Sep 17 00:00:00 2001 From: guimafelipe Date: Tue, 28 Oct 2025 10:49:23 -0700 Subject: [PATCH 37/37] Exit on build error --- TestAll.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TestAll.ps1 b/TestAll.ps1 index fd2c95050c..1f5b1e983c 100644 --- a/TestAll.ps1 +++ b/TestAll.ps1 @@ -123,7 +123,6 @@ if ($Platform -eq "AMD64") } $StartTime = Get-Date -$lastexitcode = 0 Set-StrictMode -Version 3.0 $ErrorActionPreference = 'Stop' @@ -184,6 +183,12 @@ function Build-Tests & $msbuildPath $projFile.FullName /p:Configuration=$Configuration /p:Platform=$Platform /v:minimal $projectsBuilt[$projFile.FullName] = $true + + if ($lastexitcode -ne 0) + { + Write-Error "Build failed for project $($projFile.FullName)" + Exit 1 + } } }