test_runner: fix --test-rerun-failures swallowing failures on retry#63431
Open
atlowChemi wants to merge 2 commits into
Open
test_runner: fix --test-rerun-failures swallowing failures on retry#63431atlowChemi wants to merge 2 commits into
atlowChemi wants to merge 2 commits into
Conversation
Three independent bugs interacted to let a real failure-on-retry be reported as a pass: 1. The runner's disambiguator stored the counter against the suffixed identifier (after mutation) instead of the base key, so the counter never advanced past 1 and every 3rd+ same-loc registration collided on :(1). 2. The reporter had the same off-by-one when writing the state file. 3. The reporter only bumped its counter on `test:pass`, so any failing test at a shared source location desynchronised the writer and runner counters - on retry, the surviving failing sibling would inherit a slot that in the previous attempt belonged to a different (passing) sibling. Node matched by that slot, replaced `this.fn` with a synthetic noop replay, and reported the failure as a pass. Track the base identifier separately in the runner, bump the counter against the base key in both the runner and the reporter, and bump the reporter's counter on `test:fail` in addition to `test:pass`. Fixes: nodejs#63424 Signed-off-by: atlowChemi <chemi@atlow.co.il>
Collaborator
|
Review requested:
|
Member
Author
benjamingr
approved these changes
May 19, 2026
MoLow
approved these changes
May 19, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63431 +/- ##
==========================================
- Coverage 90.05% 90.00% -0.06%
==========================================
Files 714 712 -2
Lines 225876 224852 -1024
Branches 42737 42576 -161
==========================================
- Hits 203408 202372 -1036
- Misses 14244 14338 +94
+ Partials 8224 8142 -82
🚀 New features to boost your workflow:
|
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The state-file disambiguator could mis-align between the runner and the reporter, letting a real failure-on-retry be reported as a pass. Three independent bugs interacted:
lib/internal/test_runner/test.js) — the counter was stored against the suffixed identifier instead of the base key, so it never advanced past1and every 3rd+ same-loc registration collided on:(1).lib/internal/test_runner/reporter/rerun.js) — same off-by-one when writing the state file.test:fail— onlytest:passbumped the counter, so any failing test at a shared source location desynchronised the writer and runner counters. On retry, the surviving failing sibling inherited a slot that, in the previous attempt, belonged to a different (passing) sibling. The runner matched by that slot, replacedthis.fnwith the synthetic noop replay, and reported the failure as a pass.The documented key format at
doc/api/test.md:137-140(file:line:column[:(N)]) is unchanged — the implementation now honours it correctly.Fix
test:failin addition totest:pass(still records to the state file only ontest:pass).Regression test
The new fixture
test/fixtures/test-runner/rerun-shared-helper-swallows-failure.mjsexercises two sibling groups that share a source location via a factory function:(D pass, E pass, F fail, G pass)— placed first so the passing sibling at global position 2 ends up atbase:(1). With the runner off-by-one reintroduced, the buggy counter aliases F's id onto E's recorded slot and swallows F's failure. This is the only shape that catches bug 1 in isolation.(A pass, B fail, C pass)— exercises the writer-side bugs via state-file slot assertions.Each of the three bugs was verified by reintroducing it in isolation and confirming the new test fails for the right reason.
Fixes: #63424