diff --git a/.github/actions/spelling/expect/expect.txt b/.github/actions/spelling/expect/expect.txt index 24a772ad0a..20c920b407 100644 --- a/.github/actions/spelling/expect/expect.txt +++ b/.github/actions/spelling/expect/expect.txt @@ -986,6 +986,7 @@ KVM langid LANGUAGELIST lasterror +LASTEXITCODE lastexitcode LAYOUTRTL lbl diff --git a/build/scripts/Run-Tests.ps1 b/build/scripts/Run-Tests.ps1 index ea69396569..1e52a8757e 100644 --- a/build/scripts/Run-Tests.ps1 +++ b/build/scripts/Run-Tests.ps1 @@ -1,27 +1,36 @@ [CmdLetBinding()] Param( - [Parameter(Mandatory=$true, Position=0)][string]$MatchPattern, - [Parameter(Mandatory=$true, Position=1)][string]$Platform, - [Parameter(Mandatory=$true, Position=2)][string]$Configuration, - [Parameter(Mandatory=$false, Position=3)][string]$LogPath, - [Parameter(Mandatory=$false)][string]$Root = ".\bin\$Platform\$Configuration" + [Parameter(Mandatory=$true, Position=0)] + [string]$MatchPattern, + [Parameter(Mandatory=$true, Position=1)] + [string]$Platform, + [Parameter(Mandatory=$true, Position=2)] + [string]$Configuration, + [Parameter(Mandatory=$false, Position=3)] + [string]$LogPath, + [Parameter(Mandatory=$false)] + [string]$Root = ".\bin\$Platform\$Configuration" ) -$testdlls = Get-ChildItem -Path "$Root" -Recurse -Filter $MatchPattern +# Find test DLLs based on the provided root, match pattern, and recursion +$testDlls = Get-ChildItem -Path $Root -Recurse -Filter $MatchPattern +$args = @() -$args = @(); - -if ($LogPath) -{ - $args += '/enablewttlogging'; - $args += '/appendwttlogging'; - $args += "/logFile:$LogPath"; - Write-Host "Wtt Logging Enabled"; +# Check if the LogPath parameter is provided and enable WTT logging +if ($LogPath) { + $args += '/enablewttlogging' + $args += '/appendwttlogging' + $args += "/logFile:$LogPath" + Write-Host "WTT Logging Enabled" } -&"$Root\te.exe" $args $testdlls.FullName +# Invoke the te.exe executable with arguments and test DLLs +& "$Root\te.exe" $args $testDlls.FullName -if ($lastexitcode -Ne 0) { Exit $lastexitcode } +# Check the exit code of the te.exe process and exit accordingly +if ($LASTEXITCODE -ne 0) { + Exit $LASTEXITCODE +} Exit 0