From e8789317f2571ca675ec98769fb0d49502349bf2 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sat, 26 Sep 2026 15:06:53 +0200 Subject: [PATCH] test: deflake watch cwd with isolation none Windows directory watchers report last-access time updates. Reading cold fixtures in the child can therefore trigger test:watch:restarted before it exits, failing the mustNotCall assertion without printing the error. Read the fixtures before starting watch mode and remove the Windows flaky expectation. With old access times and a delayed child exit, the original fails 10/10 runs and the change passes 100/100 on Windows. Also remove the argv variant's stale flaky expectation. It passes repeated local Windows runs and the inspected CI history after #66035. Refs: https://github.com/nodejs/node/issues/66056 Refs: https://github.com/nodejs/node/pull/66035 Signed-off-by: Filip Skokan Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/66320 Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel --- test/test-runner/test-run-watch-cwd-isolation-none.mjs | 8 +++++++- test/test-runner/test-runner.status | 5 ----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/test-runner/test-run-watch-cwd-isolation-none.mjs b/test/test-runner/test-run-watch-cwd-isolation-none.mjs index bbb1a141a4b..c3d32883781 100644 --- a/test/test-runner/test-run-watch-cwd-isolation-none.mjs +++ b/test/test-runner/test-run-watch-cwd-isolation-none.mjs @@ -1,14 +1,20 @@ // Test run({ watch: true, cwd, isolation: 'none' }) runs with different cwd while in watch mode and isolation none import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; +import { readdir, readFile } from 'node:fs/promises'; import { run } from 'node:test'; import { skipIfNoWatch } from '../common/watch.js'; skipIfNoWatch(); +// Read the fixtures before watching them. On Windows, their first read can +// update access times and trigger a restart without changing their contents. +const cwd = fixtures.path('test-runner-watch'); +await Promise.all((await readdir(cwd)).map((file) => readFile(fixtures.path('test-runner-watch', file)))); + const controller = new AbortController(); const stream = run({ - cwd: fixtures.path('test-runner-watch'), + cwd, watch: true, signal: controller.signal, isolation: 'none', diff --git a/test/test-runner/test-runner.status b/test/test-runner/test-runner.status index 7ad99e20a87..65ae96eb9e3 100644 --- a/test/test-runner/test-runner.status +++ b/test/test-runner/test-runner.status @@ -5,8 +5,3 @@ prefix test-runner # sample-test : PASS,FLAKY [true] # This section applies to all platforms - -[$system==win32] -# https://github.com/nodejs/node/issues/66056 -test-run-watch-cwd-isolation-none: PASS, FLAKY -test-run-watch-cwd-isolation-none-argv: PASS, FLAKY