From dfad81a48bd3e72cd22d2a2add4ddac9c565637e Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sun, 15 Nov 2026 03:51:30 +0800 Subject: [PATCH] test(cli): publish polled readiness files only when complete (#10563) The doctor cancellation fixture wrote its readiness JSON with writeFileSync, which truncates and then writes. The test polls only for the file's existence, so a read between the two steps parsed an empty file and failed with "Unexpected end of JSON input" (main run 43604752864, PR run 43606296871). Write to a pending path and rename it into place, as ghidraJavaDoctor and darwinProcessRunTokenReader fixtures already do. Apply the same fix to the two sibling fixtures that poll for a PID file's existence and then parse it: jadxConfiguration and runnerCancellation, where an empty read becomes PID 0. --- tests/boundary/android/jadxConfiguration.test.ts | 4 +++- tests/boundary/cli/doctorCancellation.test.ts | 4 +++- tests/process-global/runnerCancellation.test.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/boundary/android/jadxConfiguration.test.ts b/tests/boundary/android/jadxConfiguration.test.ts index e166a90963..ae3bb5fb72 100644 --- a/tests/boundary/android/jadxConfiguration.test.ts +++ b/tests/boundary/android/jadxConfiguration.test.ts @@ -508,7 +508,9 @@ const check = setInterval(() => { } }, 10); const watchdog = setTimeout(() => { process.exitCode = 99; clearInterval(check); }, 10000); -fs.writeFileSync(ready, String(process.pid)); +// The test polls for this path; publish only the complete PID by renaming. +fs.writeFileSync(ready + ".pending", String(process.pid)); +fs.renameSync(ready + ".pending", ready); `, ); await chmod(java, 0o700); diff --git a/tests/boundary/cli/doctorCancellation.test.ts b/tests/boundary/cli/doctorCancellation.test.ts index deeef4c9e3..d3e53c690e 100644 --- a/tests/boundary/cli/doctorCancellation.test.ts +++ b/tests/boundary/cli/doctorCancellation.test.ts @@ -46,7 +46,9 @@ cliTest.skipIf(!["darwin", "linux"].includes(process.platform)).for( executable, `#!${process.execPath} if (!process.argv.slice(2).includes(${JSON.stringify(probeArgument)})) process.exit(7); -require("node:fs").writeFileSync(${JSON.stringify(ready)}, JSON.stringify({pid: process.pid, runId: process.env.REA_PROCESS_RUN_ID, at: Date.now()})); +// The test polls for this path; publish only complete JSON by renaming. +require("node:fs").writeFileSync(${JSON.stringify(`${ready}.pending`)}, JSON.stringify({pid: process.pid, runId: process.env.REA_PROCESS_RUN_ID, at: Date.now()})); +require("node:fs").renameSync(${JSON.stringify(`${ready}.pending`)}, ${JSON.stringify(ready)}); process.on("SIGTERM", () => {}); setInterval(() => { if (require("node:fs").existsSync(${JSON.stringify(release)})) process.exit(0); }, 25).unref(); setTimeout(() => process.exit(99), 20000); diff --git a/tests/process-global/runnerCancellation.test.ts b/tests/process-global/runnerCancellation.test.ts index 5b33ba2ab4..5197736295 100644 --- a/tests/process-global/runnerCancellation.test.ts +++ b/tests/process-global/runnerCancellation.test.ts @@ -51,7 +51,9 @@ it.runIf(process.platform !== "win32")( const fs = require("node:fs"); process.on("SIGTERM", () => {}); fs.writeFileSync(${JSON.stringify(activityPath)}, "active\\n"); - fs.writeFileSync(${JSON.stringify(pidPath)}, String(process.pid)); + // The runner polls for this path; publish only the complete PID by renaming. + fs.writeFileSync(${JSON.stringify(`${pidPath}.pending`)}, String(process.pid)); + fs.renameSync(${JSON.stringify(`${pidPath}.pending`)}, ${JSON.stringify(pidPath)}); setInterval(() => fs.appendFileSync(${JSON.stringify(activityPath)}, "active\\n"), 20); `; const runner = launch(