test: deflake test-runner-coverage - #65728
Open
christianaurichzm wants to merge 1 commit into
Open
Conversation
The subtests that set NODE_V8_COVERAGE leave a coverage-<pid>-*.json file in the test tmpdir, and nothing removes it. The later subtests spawn without NODE_V8_COVERAGE, so their coverage goes to a private mkdtemp directory that is removed on cleanup rather than to the test tmpdir. A match in findCoverageFileForPid(result.pid) can therefore only come from a stale file whose pid has been reused, which is why the failures are only reported on platforms that recycle pids quickly. Refresh the tmpdir from an after() hook on each subtest that dumps into it, so a failure in one of them cannot leave the file behind and turn every later check into a second, misleading failure. Drop the flaky designations. Fixes: nodejs#55154 Signed-off-by: Christian Aurich <christian.aurichzm@gmail.com>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65728 +/- ##
==========================================
+ Coverage 90.07% 90.11% +0.03%
==========================================
Files 754 754
Lines 256395 256395
Branches 48494 48523 +29
==========================================
+ Hits 230947 231044 +97
+ Misses 16563 16479 -84
+ Partials 8885 8872 -13 🚀 New features to boost your workflow:
|
atlowChemi
approved these changes
Sep 2, 2026
panva
approved these changes
Sep 2, 2026
Collaborator
Member
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.
test-runner-coverageis marked flaky on Windows, Linux s390x and AIX. Every recorded failure is the same assertion:Cause
The two subtests that pass
NODE_V8_COVERAGE: tmpdir.pathleave acoverage-<pid>-<ts>-<n>.jsonfile behind, andtmpdir.refresh()only runs once, at the top of the file. The nine later checks spawn withoutNODE_V8_COVERAGE, so their coverage goes to the privatemkdtempdirectory thatsetupCoverage()creates andcleanup()removes, never to the test tmpdir.findCoverageFileForPid()keys only on the pid, so a match can only come from that stale file, once the OS hands the same pid to a later child.Reproduction
Forcing pid reuse inside a pid namespace reproduces it on Linux x64. Pushing the cursor past
RESERVED_PIDSmakes the kernel allocate cyclically within[300, pid_max), a window this test wraps through several times:tools/test.py --repeat=24 -J parallel/test-runner-coveragepasses on a normal Linux x64 run either way.Fix
Refresh the tmpdir from an
after()hook on each subtest that dumps into it. The hook rather than a trailing call matters: if an assertion in one of those subtests fails, a trailing cleanup is skipped and the stale file turns every later check into a second, misleading failure. Same forced pid reuse, with the failure injected into the last dumping subtest:after()This also drops the
PASS, FLAKYentries added in #65562 as a stopgap "while the stale coverage-file behavior is investigated"; with the stale file gone that failure path is removed, and keeping the entries would hide a regressionon those platforms.
Needs a full CI run to reach the affected configurations. The GitHub Actions Windows coverage job sets
NODE_V8_COVERAGEfor the test step, so it does not exercise this path.Fixes: #55154