test: drive coverage-flaky timing tests by timer order and events
Summary
Three tests raced real time under the Coverage job's parallelism. Each now waits on timer order or an event. No timeout was widened and nothing retries. Test-only, 5 files.
- Snapshot-source lifecycle. Fake timers advance whenever the loop idles, and the fixture's filesystem calls are in memory.
- Remote materialization timeout. Only the download timeout is faked. The test waits for staging (or settlement, or Vitest's
t.signalabort), then advances 80 ms. - Artifact tracking. Ten 1 s
vi.waitForpolls now awaitclose,abort, a held-read count, or the expectedrmSync. Timers are selected by delay within the scheduling call, not by global index.
Fixes #4321.
Validation
Tested bc5da7c53 (on 093341a60). pnpm check:affected --run --head bc5da7c53: 8 passed, 8 skipped. The first gate run had one worker SIGABRT in the unrelated src/platform-runtime-gateway.test.ts with no failed assertion; that file passed 5/5 alone and the rerun passed.
Local stress with coverage at bc5da7c53, 64 runs each (not CI's configuration):
| Test | Base | Head |
|---|---|---|
| lifecycle (32-way) | 4 failed | 0 |
| materialization timeout test (32-way) | 37 failed | 0 |
| materialization, whole file (8-way) | ā | 0 |
| artifact-tracking (32-way) | 0 | 0 |
At 32-way the file's untouched first test times out on base too, hence 8-way for the whole file. Artifact-tracking never failed locally, so that change removes the wall-clock bounds rather than a reproduced flake.
š¤ Generated with Claude Code