Commit b3962f7
fix(scripts): harden mocha-parallel-files against crashes and silent … (#8243)
* fix(scripts): harden mocha-parallel-files against crashes and silent failures
Several paths in the parallel test runner crashed the parent or hid failures
silently, mostly on Windows. Spawn errors (ENOENT, EAGAIN, EMFILE, AV blocking
the binary) emit `error` not `exit`, so the missing listener turned every
failed spawn into an uncaught parent-side exception. SIGINT/SIGTERM didn't
reach children on Windows where there's no process group to inherit. EPIPE
downgraded real test failures to exit 0. Track live children, handle all
three events, forward signals (escalating to SIGKILL after 1 s), and reuse
`process.exitCode` from the EPIPE path.
JUnit aggregation also lost data: with `jobs === 1` each child wrote its xunit
straight to `junitOutFile` and later children overwrote earlier ones, so CI
got only the last file's results. Sharding is now unconditional.
Smaller correctness fixes folded in: `--timeout 0` was treated as falsy,
the stream-end leftover got flushed without a trailing newline,
`isFailureStartLine` matched any test name containing "N failing", junit
attribute parsing returned `NaN` for malformed input, junit cleanup didn't
survive a Windows file lock, and `globSync` results were sorted per pattern
instead of globally.
* refactor(scripts): align mocha-parallel-files with project style
The bigger items: extracted `Entry` / `EntryStats` / `ParseArgsResult`
typedefs so the `/** @type {...} */ (null)` casts inside the entries factory
and `parseArgs` body go away. Renamed single-letter callback args (`m`, `l`,
`f`, `p`) to expressive names; the for-loop counter `i` in `parseArgs` stays.
Switched the one-shot child events (`message`, `exit`, `error`, `stdout` /
`stderr` 'end') from `.on` to `.once`. Added `@param` JSDoc on every callable
the diff defines or changes — closures included — plus three boy-scout
`@param` blocks on adjacent helpers (`isWarningLine`, `handleStdoutChunk`,
`handleStderrChunk`). No prose lines; method names carry the contracts.
The smaller items: `node:` prefix on the core imports, `error` instead of
`err` in catch handlers, `??` over `||` for the stat-coalesce defaults,
brace the three `if/else` sites, drop the dead `?? ''` after `parts.at(-1)`,
drop the no-op `unknown`-cast on the IPC `msg`, inline `ensureDir` (its
body was a single `fs.mkdirSync` call), and remove the `stableUnique`
one-line helper in favour of an inline `[...new Set(...)]`.1 parent c7c93d3 commit b3962f7
5 files changed
Lines changed: 429 additions & 117 deletions
File tree
- .github
- integration-tests
- mocha-parallel-files-fixtures
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
286 | 288 | | |
287 | 289 | | |
288 | 290 | | |
289 | 291 | | |
| 292 | + | |
| 293 | + | |
290 | 294 | | |
291 | 295 | | |
292 | 296 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
0 commit comments