Skip to content

Commit 1ec336b

Browse files
committed
Fail fast in run-unit-tests: stop at first failing project
Previously the script ran every unit-test project and only reported the aggregate failures at the end. Exit immediately on the first failing project for quicker feedback and to avoid spending CI time on later projects once the build is already red.
1 parent e11f4ac commit 1ec336b

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

buildtools/run-unit-tests.ps1

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ if (-not $projects)
4343
Write-Host "Running $($projects.Count) unit-test project(s):"
4444
$projects | ForEach-Object { Write-Host " - $_" }
4545

46-
$failed = @()
4746
foreach ($project in $projects)
4847
{
4948
$name = [System.IO.Path]::GetFileNameWithoutExtension($project)
@@ -52,18 +51,13 @@ foreach ($project in $projects)
5251
dotnet test -c $Configuration $project
5352
if ($LASTEXITCODE -ne 0)
5453
{
55-
Write-Host "Tests failed for $name (exit $LASTEXITCODE)."
56-
$failed += $name
54+
# Fail fast: stop at the first failing project rather than running the rest. This gives
55+
# quicker feedback and avoids spending CI time on later projects once the build is red.
56+
Write-Host ""
57+
Write-Host "Tests failed for $name (exit $LASTEXITCODE). Stopping without running the remaining project(s)."
58+
exit 1
5759
}
5860
}
5961

60-
if ($failed)
61-
{
62-
Write-Host ""
63-
Write-Host "The following unit-test project(s) failed:"
64-
$failed | ForEach-Object { Write-Host " - $_" }
65-
exit 1
66-
}
67-
6862
Write-Host ""
6963
Write-Host "All unit-test projects passed."

0 commit comments

Comments
 (0)