Files
reims-vgpu/scripts/test-isolation
Anees Iqbal 4b83c8baac ✨ The sweep that found the last two order-dependent tests is now a script, because a green suite is not evidence that its tests are independent
New `scripts/test-isolation/`, plus its row in `AGENTS.md`'s instrument table.
No crate code.

WHAT IT ANSWERS

"Does a test pass only because of what ran before it?" Runs every `--lib` test
in its own process and diffs the isolated result against the in-suite one.
Both directions are findings, and it reports them separately:

- **pass in-suite, fail alone** — the test needs a predecessor, so its
  assertion is not proving what it claims. It is proving something about the
  process the suite happened to hand it.
- **fail in-suite, pass alone** — the test was poisoned by a predecessor.

WHY THE SUITE CANNOT ANSWER IT

The suite is one process, and several things this crate keeps for a whole boot
outlive the test that touched them: `first_sight` and `state_changed`'s
registries, `observe::sink`'s process-monotonic clock, `draw_phase`'s `ACC`
accumulators, and every `OnceLock`. Whether two tests interact through one of
them depends on which runs first, and libtest orders by name — so the answer
changes when a module is renamed, which is exactly how this class surfaced
three commits ago. A green suite is evidence about one ordering.

The three findings so far, all real, none visible to any existing gate: a
`first_sight` collision between two fixtures that picked the same PFN; an
assertion on a clock that reads zero for the first microsecond of a run; and an
`== 0` on a phase slot that legitimately accumulates the cost of one statement.

PROVEN ABLE TO REPORT

A green instrument on a clean tree proves nothing, so it was run against a
deliberate defect: a temporary pair of tests where the alphabetically earlier
one spends a `first_sight` latch the later one asserts on. The script named
`zzz_needs_an_unclaimed_probe_latch` under "poisoned by one" and exited
non-zero. Scaffold removed; the run after it is clean at 1,408 tests.

It also refuses a verdict rather than reporting a clean sweep, twice: when the
built `--lib` binary cannot be located, and when `--list` yields fewer than 100
tests. A `--list` that stopped working — a libtest format change, a build that
produced no tests — otherwise reads exactly like a suite with no
order-dependence in it, which is the failure mode `AGENTS.md` calls out for
every instrument here.

The README carries the triage, including the rule the two fixes established:
the cure is never to relax the assertion until it passes. Both cures made the
test strictly stronger, and both were re-checked by restoring the bug.

VERIFIED

- Clean run on this tree: 1,408 tests, no order-dependence, exit 0.
- Non-zero exit and a correct name on the injected defect, as above.
- Takes a few minutes and is timing-insensitive, so unlike a boot it is safe to
  run beside other work. Said so in the README.

NOT VERIFIED

- The `--features backend-metal` arm of the script is accepted and passed
  through but has never been run; that needs an Apple host.
- It only sees the `--lib` binary. The 21 integration binaries each run in
  their own process already, but a multi-test integration binary can carry the
  same coupling internally and this does not look. Recorded as a known limit in
  the README rather than left for the next reader to discover.
2026-08-05 21:09:27 +03:00
..

test-isolation

Runs every --lib test in its own process and diffs the result against the in-suite one. A difference in either direction means the test's verdict is partly a property of what ran before it.

scripts/test-isolation/test-isolation.sh
scripts/test-isolation/test-isolation.sh --features backend-metal   # Apple hosts only

Takes a few minutes: one process per test, and this crate's --lib binary is large. Nothing about it is timing-sensitive, so it is safe to run beside other work — unlike a boot.

Why this is not covered by running the suite

The suite is one process, and several things this crate keeps for a whole boot outlive the test that touched them:

  • observe::emit's first_sight and state_changed registries,
  • observe::sink's process-monotonic clock (elapsed_us reads 0 for the first microsecond of a run and never again),
  • the ACC phase accumulators in backend/vulkan/engine/draw_phase.rs,
  • every OnceLock in the crate, including the resolved log paths.

Whether two tests interact through one of these depends on which runs first, and libtest orders by name — so the answer changes when a module is renamed. It changed for real: renaming runtime::metal_draw to runtime::draw moved several hundred tests across runtime::mapper and turned a green suite red.

Triage

Pass in-suite, fail alone. The test needs a predecessor. This is the common class and it is always a finding, because the assertion is not proving what it claims — it is proving something about the process the suite happened to hand it. Both hits on the first run of this script were assertions that a correct implementation can violate:

  • landed_us > 0, where the value is a reading of a clock that starts at zero. The cure is to establish the precondition the assertion needs (wait for the clock to leave zero) and then assert the real property (the stamp lies between readings taken either side of the call), not to relax the bound.
  • acquire_us == 0, where the slot legitimately accumulates the cost of one statement — sub-microsecond in a warm process, 8 µs in a cold one. The cure is a ceiling derived from the constant the test already declares, chosen so it cannot be satisfied by the failure the assertion guards.

Neither cure is "make the assertion looser until it passes". Both made the test strictly stronger; check yours does too, by restoring the bug it guards and watching it go red.

Fail in-suite, pass alone. The test was poisoned by a predecessor. For a capturing test this should now be impossible by construction — FailCapture::start drops both dedup registries — so a hit here means either a test that reaches an emitter without capturing the sink, or a fifth piece of process state not on the list above. Find which, and prefer removing the mechanism over renaming a fixture value around it.

How it can mislead

  • It only sees --lib. The 21 integration binaries each run in their own process already, but a multi-test integration binary can carry the same coupling internally and this script will not look.
  • A test that is order-dependent but whose neighbours never trigger it reads clean. This measures the ordering that exists today, not every ordering. A clean run is evidence about this tree, not a proof about the next rename.
  • It refuses a verdict below 100 listed tests rather than reporting a clean sweep over nothing, since a --list that stopped working looks exactly like a suite with no order-dependence in it.