Commit 8ee6c69
committed
fix: Properly preserve exit codes in run and run-workers commands
- Use beforeExit handler to set force-exit timeout AFTER Mocha sets exit codes
- This ensures failed tests correctly propagate exit code 1 to parent process
- Also change process.exit(1) to process.exitCode = 1 in error handlers
- Add same force-exit logic to run-workers command for consistency
Fixes test:runner failures where tests expected err.code=1 but got err=null.
The issue was that our previous force-exit implementation called process.exit()
before Mocha's exit handlers could set the correct exit code, causing the
process to always exit with code 0 regardless of test failures.
This fix ensures:
1. Mocha and other exit handlers run first and set correct exit codes
2. Force-exit still happens to prevent hanging from leftover handles
3. Exit codes are properly propagated to parent processes (e.g., in exec())
All 244 test:runner tests now pass.1 parent 808bba3 commit 8ee6c69
2 files changed
+23
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
78 | 92 | | |
79 | 93 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
0 commit comments