diff --git a/test.ps1 b/test.ps1 index 6b110b383..3a0b2c809 100644 --- a/test.ps1 +++ b/test.ps1 @@ -285,3 +285,15 @@ if ($CC) { if ("Failed" -eq $r.Result) { throw "Run failed!" } + +# Every test passed, so say so with the exit code as well. +# +# Invoke-InNewProcess deliberately lets the child's exit code through, and tests assert on +# it (see "Exitcode is set to the number of failed tests..."), so the helper cannot reset it. +# That means whichever test ran last decides what $LASTEXITCODE holds when we get here, and +# CI ends the step with `exit $LASTEXITCODE`. Without this line a child that exited non-zero +# on purpose turns a fully green run red with no failing test to look at. +# +# This sits after both failure paths above, `exit 1` for P tests and the throw for a failed +# run, so it cannot hide a real failure. +$global:LASTEXITCODE = 0