test: avoid repeated writes in watch helper

Use performFileOperation() for test runner watch updates so the
run() API path schedules a single delayed write instead of rewriting
the file until the second run completes.

Repeated writes can trigger another watch restart while the previous
rerun is still active. The runner then terminates the in-flight child
process with SIGTERM, which can make the captured output include both
a failed file-level subtest and the next successful run.

Also count only root summary duration lines when detecting completed
runs.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
PR-URL: https://github.com/nodejs/node/pull/63386
Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-05-17.md#jstest-failure
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
Trivikram Kamat authored and GitHub committed 2026-05-19 19:16:51 +00:00
1 parent b1387e6aed
commit 0b5b189426
1 file changed
+6 -13
+6 -13
View File
@@ -106,7 +106,7 @@ async function testRunnerWatch({
child.stdout.on('data', (data) => {
stdout += data.toString();
currentRun += data.toString();
const testRuns = stdout.match(/duration_ms\s\d+/g);
const testRuns = stdout.match(/^\S+ duration_ms\s\d+/gm);
if (testRuns?.length >= 1) ran1.resolve();
if (testRuns?.length >= 2) ran2.resolve();
});
@@ -118,18 +118,11 @@ async function testRunnerWatch({
const content = fixtureContent[fileToUpdate];
const path = fixturePaths[fileToUpdate];
if (useRunApi) {
const interval = setInterval(
() => writeFileSync(path, content),
common.platformTimeout(1000),
);
await ran2.promise;
clearInterval(interval);
} else {
writeFileSync(path, content);
await setTimeout(common.platformTimeout(1000));
await ran2.promise;
}
await performFileOperation(
() => writeFileSync(path, content),
useRunApi,
);
await ran2.promise;
runs.push(currentRun);
child.kill();