From ed4e5df638967e0be8dbd2eab2a617a6c9176dd4 Mon Sep 17 00:00:00 2001 From: Christian Aurich Date: Thu, 3 Sep 2026 20:54:01 -0300 Subject: [PATCH] test: deflake test-runner-coverage The subtests that set NODE_V8_COVERAGE leave a coverage--*.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: https://github.com/nodejs/node/issues/55154 Signed-off-by: Christian Aurich PR-URL: https://github.com/nodejs/node/pull/65728 Reviewed-By: Chemi Atlow Reviewed-By: Filip Skokan Reviewed-By: Trivikram Kamat --- test/parallel/parallel.status | 6 ------ test/parallel/test-runner-coverage.js | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 7430d5ea66e..6ad39e37f94 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -35,8 +35,6 @@ test-snapshot-reproducible: SKIP test-repl-user-error-handler: PASS, FLAKY [$system==win32] -# https://github.com/nodejs/node/issues/55154#issuecomment-5423571475 -test-runner-coverage: PASS, FLAKY # https://github.com/nodejs/node/issues/59090 test-inspector-network-fetch: PASS, FLAKY # https://github.com/nodejs/node/issues/59636 @@ -53,8 +51,6 @@ test-performance-function: PASS, FLAKY test-esm-loader-hooks-inspect-wait: PASS, FLAKY [$system==linux && $arch==s390x] -# https://github.com/nodejs/node/issues/55154#issuecomment-5423571475 -test-runner-coverage: PASS, FLAKY # https://github.com/nodejs/node/issues/58353 test-http2-debug: PASS, FLAKY @@ -116,8 +112,6 @@ test-fs-watch-ignore-mixed: SKIP test-fs-watch-ignore-regexp: SKIP [$system==aix] -# https://github.com/nodejs/node/issues/55154#issuecomment-5423571475 -test-runner-coverage: PASS, FLAKY # https://github.com/nodejs/node/issues/54346 test-esm-loader-hooks-inspect-wait: PASS, FLAKY # https://github.com/nodejs/node/issues/65697 diff --git a/test/parallel/test-runner-coverage.js b/test/parallel/test-runner-coverage.js index 542078c93d5..8e87b0a6092 100644 --- a/test/parallel/test-runner-coverage.js +++ b/test/parallel/test-runner-coverage.js @@ -116,6 +116,8 @@ test('test coverage report', async (t) => { test('test tap coverage reporter', skipIfNoInspector, async (t) => { await t.test('coverage is reported and dumped to NODE_V8_COVERAGE if present', (t) => { + // A dump left here would match the negative checks below on pid reuse. + t.after(() => tmpdir.refresh()); const fixture = fixtures.path('test-runner', 'coverage.js'); const args = [ '--experimental-test-coverage', @@ -154,6 +156,8 @@ test('test tap coverage reporter', skipIfNoInspector, async (t) => { test('test spec coverage reporter', skipIfNoInspector, async (t) => { await t.test('coverage is reported and dumped to NODE_V8_COVERAGE if present', (t) => { + // A dump left here would match the negative checks below on pid reuse. + t.after(() => tmpdir.refresh()); const fixture = fixtures.path('test-runner', 'coverage.js'); const args = [ '--experimental-test-coverage',