From 8f08bd108a62b8dfb1c0db72efbeb09f5e713c09 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Sun, 17 May 2026 10:53:19 -0700 Subject: [PATCH] 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 --- test/common/watch.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/test/common/watch.js b/test/common/watch.js index 81defc49835eb1..c3d22c30f78e0c 100644 --- a/test/common/watch.js +++ b/test/common/watch.js @@ -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();