Public: anyone can read this; the crew can change it.
A red test run that named no failing test and no crash says so plainly, never its last stray line #17228
Merged 44h 37m ago, live in production
fix/summary-names-nothing → main 0 commits 1 thread · 1 unresolved
2 files
changed +68
−2
src/checks/summary.ts +38 −2
| @@ -35,6 +35,32 @@ const UNNAMED_SHARD = | ||
| 35 | 35 | const RECORD_KEEPING = |
| 36 | 36 | /^test-shards: (?:wrote [0-9]+ (?:times|test impacts) to |kept [0-9]+ green results in |not writing |not recording: )/; |
| 37 | 37 | |
| 38 | /** | |
| 39 | * A line only a test run prints: the gate's own, bun test's, or a file's time in a list of them. | |
| 40 | */ | |
| 41 | const TEST_RUN = | |
| 42 | /^(?:test-shards: |bun test v\d|\((?:pass|fail|skip|todo)\) |[0-9.]+s test\/\S+\.test\.[cm]?[jt]sx?$)/; | |
| 43 | ||
| 44 | /** | |
| 45 | * The gate's notes on how the run went (a plan, a shard starting, its times): never why it is red. | |
| 46 | */ | |
| 47 | const TEST_RUN_NOTE = new RegExp( | |
| 48 | "^test-shards: (?:start [0-9]+/[0-9]+|[0-9]+ files in [0-9]+ shards|SLOW files|over budget|" + | |
| 49 | "fast tier|full tier|by reason|--changed|[0-9]+ rule and scan files first|space after a red shard)", | |
| 50 | ); | |
| 51 | ||
| 52 | /** | |
| 53 | * A test run's noise: how it went, never why it is red. A passing or skipped test, bun's banner, | |
| 54 | * a file's name or counts, a file's time, a note or the record-keeping of the gate's. | |
| 55 | */ | |
| 56 | const isNoise = (line: string): boolean => | |
| 57 | line === "" || | |
| 58 | RECORD_KEEPING.test(line) || | |
| 59 | TEST_RUN_NOTE.test(line) || | |
| 60 | /^(?:bun test v\d|\((?:pass|skip|todo)\) |[0-9.]+s test\/\S+\.test\.[cm]?[jt]sx?$)/.test(line) || | |
| 61 | /^\S+\.test\.[cm]?[jt]sx?:$/.test(line) || | |
| 62 | /^[0-9]+ (?:pass|fail|skip|todo|expect\(\) calls)$/.test(line); | |
| 63 | ||
| 38 | 64 | /** |
| 39 | 65 | * Whether `runStep`'s error is the step's own exit ("check exited with code |
| 40 | 66 | * 1"); anything else — a cell's limit, a signal, a timeout, a cancel, a lost |
| @@ -103,8 +129,18 @@ export function summariseCheckFailure( | ||
| 103 | 129 | if (unnamed !== undefined) |
| 104 | 130 | return { summary: truncate(unnamed.trim()), detail: undefined }; |
| 105 | 131 | const block = lines.findLastIndex((line) => line.trim() === GATE_SUMMARY_HEADING); |
| 106 | for (let i = (block === -1 ? lines.length : block) - 1; i >= 0; i--) { | |
| 107 | const line = lines[i]!.trim(); | |
| 132 | const before = lines.slice(0, block === -1 ? lines.length : block).map((line) => line.trim()); | |
| 133 | // A test run's output: its last line that is not noise is why it is red (a crash, a module it | |
| 134 | // could not find, its tally, a note of the gate's own). When only noise is left, a timing or a | |
| 135 | // shard starting, it named nothing, and says so plainly: #17173 read "0.3s | |
| 136 | // test/origin-every-mutation.test.ts" when the runner's tally never arrived. | |
| 137 | if (before.some((line) => TEST_RUN.test(line))) { | |
| 138 | const said = before.findLast((line) => !isNoise(line)); | |
| 139 | const plain = `${fallback} and named no failing test: its output may be incomplete`; | |
| 140 | return { summary: truncate(said ?? plain), detail: undefined }; | |
| 141 | } | |
| 142 | for (let i = before.length - 1; i >= 0; i--) { | |
| 143 | const line = before[i]!; | |
| 108 | 144 | if (line !== "" && !RECORD_KEEPING.test(line)) return { summary: truncate(line), detail: undefined }; |
| 109 | 145 | } |
| 110 | 146 | return { summary: fallback, detail: undefined }; |
test/checks-failure-summary.test.ts +30
| @@ -295,6 +295,36 @@ describe("summariseCheckFailure: a red gate is summarised by its red test, never | ||
| 295 | 295 | expect(summariseCheckFailure(lines, "check exited with code 1").summary).toBe("test-shards: something went wrong"); |
| 296 | 296 | }); |
| 297 | 297 | |
| 298 | // #17173 (2026-12-01): the runner's tally never arrived, and the summary was a file's time. | |
| 299 | test("a test run that named no failing test and no crash says so plainly, never its last stray line", () => { | |
| 300 | const lines = [ | |
| 301 | "test-shards: start 142/159 test/a.test.ts test/b.test.ts", | |
| 302 | "test-shards: SLOW files this run, their tests' seconds summed: 3", | |
| 303 | " 0.3s test/origin-every-mutation.test.ts", | |
| 304 | " 0.2s test/game-diag.test.ts", | |
| 305 | ]; | |
| 306 | expect(summariseCheckFailure(lines, "check exited with code 1")).toEqual({ | |
| 307 | summary: "check exited with code 1 and named no failing test: its output may be incomplete", | |
| 308 | detail: undefined, | |
| 309 | }); | |
| 310 | // Even the times alone are a test run's. | |
| 311 | expect(summariseCheckFailure([" 0.3s test/a.test.ts"], "check exited with code 1").summary).toBe( | |
| 312 | "check exited with code 1 and named no failing test: its output may be incomplete", | |
| 313 | ); | |
| 314 | }); | |
| 315 | ||
| 316 | test("a test run that died on a real line keeps that line: a module it could not find, a crash", () => { | |
| 317 | const died = (line: string) => [ | |
| 318 | "test-shards: start 1/2 test/a.test.ts", | |
| 319 | "test/a.test.ts:", | |
| 320 | "(pass) a works [0.20ms]", | |
| 321 | line, | |
| 322 | " 0.3s test/a.test.ts", | |
| 323 | ]; | |
| 324 | for (const line of ['error: Cannot find module "x" from "test/a.test.ts"', "Segmentation fault (core dumped)", "panic(main thread): Illegal instruction"]) | |
| 325 | expect(summariseCheckFailure(died(line), "check exited with code 1").summary).toBe(line); | |
| 326 | }); | |
| 327 | ||
| 298 | 328 | test("a check stopped from outside is summarised by the stop, not its last printed line", () => { |
| 299 | 329 | const lines = ["Ran 4000 tests across 900 files in 1200.0s (16 shards).", "test-shards: kept 147 green results in .forge-kept.json"]; |
| 300 | 330 | for (const stop of [ |
new above
offline