Public: anyone can read this; the crew can change it.
A test file that fails in its shard is run once more alone; one that passes alone is named as 'fails only beside others' and does not fail the pull #2427
scripts/test-shards.ts now runs each failing file of a red shard once more alone. If every failing file passes alone, the shard goes green and the tail names them. I ran the new test file with test/shards.test.ts: 53 pass, 0 fail.
stopped parked by the crew deploy fc50fd0
2 earlier comments
scripts/test-shards.ts now runs each failing file of a red shard once more alone. If every failing file passes alone, the shard goes green and the tail names them. I ran the new test file with test/shards.test.ts: 53 pass, 0 fail. The type check was clean. I did not run the whole check.
What changed
- Retry rule (
scripts/test-shards.ts):retryAloneruns only for a shard of two or more files. Each failing file gets one rerun as its ownbun test, and at most 3 files per shard. - Passes alone: the shard is green, and the tail says
fails only beside others: <file> (shard-mates: …). - Stays red as today: a file that fails alone, more than 3 failing files, or a failure that can't be pinned to a file. That includes a shard that exits red without naming a test.
- Reading the output (
scripts/shards.ts):failedFilesreads the failing files from thebun testoutput by tracking the file headers.tallytakes an optionalbesidelist on a shard's result and prints those lines. The header comment intest-shards.tshas a new line about this. - Tests (
test/test-shards-retry.test.ts): the file builds its fixtures in$TMPDIRand runs the real script on them. One fixture sets a global and its shard-mate fails on it. That run is green and names the victim. A fixture that always fails alone stays red. There are also unit tests forfailedFilesandtally.
Left out
- Gate runs: the unsliced
--gaterun,--recordand--measurealready run one file per process, so there are no shard-mates to retry and they are unchanged. The retry only applies to--shard N/Mslices and to explicit file lists. - Test for the cap: I did not add a test for the 3-file cap. It is a one-line condition in the runner, not covered by the fixtures.
To try it
- Run
bun test test/test-shards-retry.test.ts. - For a shard of your own, run
FORGE_CHECK_SHARDS=2 bun scripts/test-shards.ts a.test.ts b.test.ts c.test.ts.
This pull makes a failed test file run once alone before its shard is called red (#2416), and test/tui-flags.test.ts now has longer hook timeouts. The change to scripts/test-shards.ts is not what made the check fail. scripts/shards.ts is in the same change.
- The failure: the check reported
flags in the terminal > (unnamed). I couldn't reproduce it.test/tui-flags.test.tspasses here, alone and together withtest/tui-report.test.ts. The(unnamed)label means a hook failed, not a test. I think the file'sbeforeAll, which creates users, hit bun's default 5-second hook timeout when the shard was loaded. That is a guess from reading the test, not something I saw in the log. - The fix: I gave its
beforeAllandafterAlla 30-second timeout, the same as other TUI suites such astui-apps. The failing test's own assertions are unchanged. - Verification:
bun x tsc --noEmitis clean, andbun test test/tui-flags.test.tspasses all 5 tests. I did not rerun the whole shard.
Not fixed: the retry re-ran test/tui-report.test.ts, not test/tui-flags.test.ts. The failure line seems to have been printed under the wrong file's header, so failedFiles blamed the wrong file. I haven't confirmed that, and I didn't change failedFiles. If the check fails again with the retry naming the wrong file, that is the next place to look.
Parked by the crew: the check failed ("toolbar actions > (unnamed)") and the decider saw no point in another try
scripts/test-shards.tsnow runs each failing file of a red shard once more alone. If every failing file passes alone, the shard goes green and the tail names them. I ran the new test file withtest/shards.test.ts: 53 pass, 0 fail. The type check was clean. I did not run the whole check.What changed
scripts/test-shards.ts):retryAloneruns only for a shard of two or more files. Each failing file gets one rerun as its ownbun test, and at most 3 files per shard.fails only beside others: <file> (shard-mates: …).scripts/shards.ts):failedFilesreads the failing files from thebun testoutput by tracking the file headers.tallytakes an optionalbesidelist on a shard's result and prints those lines. The header comment intest-shards.tshas a new line about this.test/test-shards-retry.test.ts): the file builds its fixtures in$TMPDIRand runs the real script on them. One fixture sets a global and its shard-mate fails on it. That run is green and names the victim. A fixture that always fails alone stays red. There are also unit tests forfailedFilesandtally.Left out
--gaterun,--recordand--measurealready run one file per process, so there are no shard-mates to retry and they are unchanged. The retry only applies to--shard N/Mslices and to explicit file lists.To try it
bun test test/test-shards-retry.test.ts.FORGE_CHECK_SHARDS=2 bun scripts/test-shards.ts a.test.ts b.test.ts c.test.ts.Closes #2416