From f86b5141f56fa4326020ba5687ec33fd46a5fbbc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Oct 2025 20:44:48 +0200 Subject: [PATCH 1/3] Update for PR --- scripts/main.ps1 | 72 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 11 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 14da9fa..6bf2c8e 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -75,8 +75,9 @@ LogGroup 'Expected test suites' { $isFailure = $false $testResults = [System.Collections.Generic.List[psobject]]::new() -$failedTests = [System.Collections.Generic.List[psobject]]::new() -$unexecutedTests = [System.Collections.Generic.List[psobject]]::new() +$failedTests = [System.Collections.Generic.List[string]]::new() +$unexecutedTests = [System.Collections.Generic.List[string]]::new() +$missingResultFiles = [System.Collections.Generic.List[string]]::new() $totalErrors = 0 foreach ($expected in $expectedTestSuites) { @@ -109,14 +110,21 @@ foreach ($expected in $expectedTestSuites) { } # Determine if there’s any failure for this single test file + $hasTestsValue = $null -ne $result.Tests + $hasPassedValue = $null -ne $result.Passed + $hasFailedValue = $null -ne $result.Failed + $hasInconclusiveValue = $null -ne $result.Inconclusive + $hasNotRunValue = $null -ne $result.NotRun + $testFailure = ( $result.Result -ne 'Passed' -or $result.Executed -ne $true -or $result.ResultFilePresent -eq $false -or - $result.Tests -eq 0 -or - $result.Passed -eq 0 -or - $result.Failed -gt 0 -or - $result.Inconclusive -gt 0 + ($hasTestsValue -and $result.Tests -eq 0) -or + ($hasPassedValue -and $hasTestsValue -and $result.Tests -gt 0 -and $result.Passed -eq 0) -or + ($hasFailedValue -and $result.Failed -gt 0) -or + ($hasInconclusiveValue -and $result.Inconclusive -gt 0) -or + ($hasNotRunValue -and $result.NotRun -gt 0) ) if ($testFailure) { @@ -133,15 +141,53 @@ foreach ($expected in $expectedTestSuites) { $logGroupName = $expected.Name -replace '-TestResult-Report.*', '' LogGroup " - $color$logGroupName$reset" { + $failureReasons = [System.Collections.Generic.List[string]]::new() + + if ($result.ResultFilePresent -eq $false) { + $missingResultFiles.Add($expected.Name) + $failureReasons.Add("Result file '$($expected.Name)' was not found in the artifacts.") | Out-Null + } + if ($result.Executed -eq $false) { $unexecutedTests.Add($expected.Name) - Write-GitHubError "Test was not executed as reported in file: $($expected.Name)" - $totalErrors++ - } elseif ($result.Result -eq 'Failed') { - $failedTests.Add($expected.Name) - Write-GitHubError "Test result explicitly marked as Failed in file: $($expected.Name)" + $failureReasons.Add("Test execution flag is false in file: $($expected.Name)") | Out-Null + } + + if ($result.Result -and $result.Result -ne 'Passed') { + if ($failedTests -notcontains $expected.Name) { + $failedTests.Add($expected.Name) + } + $failureReasons.Add("Test result value '$($result.Result)' indicates failure in file: $($expected.Name)") | Out-Null + } + + if ($hasTestsValue -and $result.Tests -eq 0) { + $failureReasons.Add("No tests were reported in file: $($expected.Name)") | Out-Null + } + + if ($hasPassedValue -and $hasTestsValue -and $result.Tests -gt 0 -and $result.Passed -eq 0) { + $failureReasons.Add("No tests passed according to file: $($expected.Name)") | Out-Null + } + + if ($hasFailedValue -and $result.Failed -gt 0) { + if ($failedTests -notcontains $expected.Name) { + $failedTests.Add($expected.Name) + } + $failureReasons.Add("$($result.Failed) tests failed in file: $($expected.Name)") | Out-Null + } + + if ($hasInconclusiveValue -and $result.Inconclusive -gt 0) { + $failureReasons.Add("$($result.Inconclusive) tests were inconclusive in file: $($expected.Name)") | Out-Null + } + + if ($hasNotRunValue -and $result.NotRun -gt 0) { + $failureReasons.Add("$($result.NotRun) tests were not run in file: $($expected.Name)") | Out-Null + } + + foreach ($reason in $failureReasons) { + Write-GitHubError $reason $totalErrors++ } + $result | Format-Table | Out-String } @@ -181,6 +227,10 @@ LogGroup " - $color`Summary$reset" { Write-Host 'Unexecuted Test Files' $unexecutedTests | ForEach-Object { Write-Host " - $_" } } + if ($missingResultFiles.Count -gt 0) { + Write-Host 'Missing Test Result Files' + $missingResultFiles | ForEach-Object { Write-Host " - $_" } + } } exit $totalErrors From 0f81c654e6d4e64ed30c7d72158908c0b7bd4cd6 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Oct 2025 21:34:43 +0200 Subject: [PATCH 2/3] Replace | Out-Null with = for better performance --- scripts/main.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 6bf2c8e..6df1620 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -145,42 +145,42 @@ foreach ($expected in $expectedTestSuites) { if ($result.ResultFilePresent -eq $false) { $missingResultFiles.Add($expected.Name) - $failureReasons.Add("Result file '$($expected.Name)' was not found in the artifacts.") | Out-Null + $null = $failureReasons.Add("Result file '$($expected.Name)' was not found in the artifacts.") } if ($result.Executed -eq $false) { $unexecutedTests.Add($expected.Name) - $failureReasons.Add("Test execution flag is false in file: $($expected.Name)") | Out-Null + $null = $failureReasons.Add("Test execution flag is false in file: $($expected.Name)") } if ($result.Result -and $result.Result -ne 'Passed') { if ($failedTests -notcontains $expected.Name) { $failedTests.Add($expected.Name) } - $failureReasons.Add("Test result value '$($result.Result)' indicates failure in file: $($expected.Name)") | Out-Null + $null = $failureReasons.Add("Test result value '$($result.Result)' indicates failure in file: $($expected.Name)") } if ($hasTestsValue -and $result.Tests -eq 0) { - $failureReasons.Add("No tests were reported in file: $($expected.Name)") | Out-Null + $null = $failureReasons.Add("No tests were reported in file: $($expected.Name)") } if ($hasPassedValue -and $hasTestsValue -and $result.Tests -gt 0 -and $result.Passed -eq 0) { - $failureReasons.Add("No tests passed according to file: $($expected.Name)") | Out-Null + $null = $failureReasons.Add("No tests passed according to file: $($expected.Name)") } if ($hasFailedValue -and $result.Failed -gt 0) { if ($failedTests -notcontains $expected.Name) { $failedTests.Add($expected.Name) } - $failureReasons.Add("$($result.Failed) tests failed in file: $($expected.Name)") | Out-Null + $null = $failureReasons.Add("$($result.Failed) tests failed in file: $($expected.Name)") } if ($hasInconclusiveValue -and $result.Inconclusive -gt 0) { - $failureReasons.Add("$($result.Inconclusive) tests were inconclusive in file: $($expected.Name)") | Out-Null + $null = $failureReasons.Add("$($result.Inconclusive) tests were inconclusive in file: $($expected.Name)") } if ($hasNotRunValue -and $result.NotRun -gt 0) { - $failureReasons.Add("$($result.NotRun) tests were not run in file: $($expected.Name)") | Out-Null + $null = $failureReasons.Add("$($result.NotRun) tests were not run in file: $($expected.Name)") } foreach ($reason in $failureReasons) { From 13bdb6419867e155b7cf8d5c3d590f6304a91173 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Oct 2025 21:46:18 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=AA=B2=20[Fix]:=20Replace=20Format-Ta?= =?UTF-8?q?ble=20with=20Write-Host=20for=20better=20output=20visibility=20?= =?UTF-8?q?in=20test=20results?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 6df1620..272030a 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -188,7 +188,7 @@ foreach ($expected in $expectedTestSuites) { $totalErrors++ } - $result | Format-Table | Out-String + Write-Host "$($result | Format-Table | Out-String)" } if ($result.ResultFilePresent) {