Commit 58f88af
authored
Fix unit test failures not failing the build (#33423)
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
## Description
This PR fixes a critical issue where unit test failures were not
properly failing the build pipeline, allowing PRs to pass CI checks even
when tests failed.
## Problem
In `/eng/pipelines/common/run-dotnet-preview.yml` at line 58, when
`useExitCodeForErrors: true` is set and tests fail, the script was:
1. ✅ Logging an error message
2. ✅ Marking the task as "Failed" using Azure DevOps logging commands
3. ❌ **Exiting with code 0 (success)**
This caused jobs to show as `succeededWithIssues` instead of `failed`,
and overall PR checks would pass even though unit tests failed.
### Example
PR #33391 had failing unit tests:
- Controls.Xaml.UnitTests failed with "Test suite had 1 failure(s)"
- Build timeline showed `"result": "succeededWithIssues"`
- But overall check status was SUCCESS ✅
## Solution
Changed line 58 from:
```powershell
exit 0
```
to:
```powershell
exit $LASTEXITCODE
```
This ensures the PowerShell script exits with the actual failure code
from the test run, properly failing the build pipeline.
## Impact
After this change:
- ✅ Unit test failures will properly fail the build
- ✅ PR checks will show as failed when tests fail
- ✅ Build status will accurately reflect test results
- ✅ No more false positives where builds pass with failing tests
## Testing
This fix will be validated by observing the build behavior on this PR
itself. The change is minimal and surgical - only affecting the exit
code propagation when tests fail.1 parent 347d26c commit 58f88af
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
0 commit comments