Skip to content

bun test: detect obsolete snapshots and fix -u "added" mislabel - #34042

Closed
robobun wants to merge 11 commits into
mainfrom
farm/f88d2771/snapshot-obsolete-detection
Closed

robobun wants to merge 11 commits into
mainfrom
farm/f88d2771/snapshot-obsolete-detection

ci: retrigger

0e2df79
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 12, 2026 in 28m 55s

Code review found 1 important issue

Found 4 candidates, confirmed 6. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 5
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/runtime/test_runner/Execution.rs:721-727 test.failing() that throws is not noted, causing false-positive obsolete
🟡 Nit src/runtime/test_runner/snapshot.rs:356-371 had_only_in_file leaks across files when .only() file has no toMatchSnapshot

Annotations

Check warning on line 727 in src/runtime/test_runner/Execution.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

test.failing() that throws is not noted, causing false-positive obsolete

The `!= Result::Pass` guard misses one path: a `test.failing()` body that throws. `handle_uncaught_exception` sets `sequence.result = Result::Pass` for `ScopeMode::Failing` (with `maybe_skip = true`), so any `toMatchSnapshot()` after the throw is never reached and its key stays in `unchecked_keys` — but `note_skipped_test` is skipped because the result is `Pass`, and the key is tallied as obsolete on a green run. Simplest fix: drop the guard and note every completed test (a truly-passing test's 

Check warning on line 371 in src/runtime/test_runner/snapshot.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

had_only_in_file leaks across files when .only() file has no toMatchSnapshot

Same structural issue as the `skipped_test_names` retain above, but with a correctness effect: `had_only_in_file` is set in `on_sequence_completed` whenever a file's root scope has `.only()`, but only reset here inside the `if let Some(file)` block. If file A has `test.only()` on a test that never calls `toMatchSnapshot()`, `_current_file` stays `None`, so when file B's `get_snapshot_file` calls `write_snapshot_file()` the body is skipped and the flag stays `true` — file B's genuinely-obsolete k