mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
test(process): publish timeout stop signal atomically in ExecFileOutput test (#13151)
The child recorded the received signal with writeFileSync, which creates an empty file before writing. The test polls for existence and reads the content while the child is still alive, so it could observe '' instead of SIGINT (main CI run 44898480483). Write to a sibling file and rename it. Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
1 file changed
+4
-1
@@ -352,10 +352,13 @@ describe.skipIf(process.platform === "win32")(
|
||||
const ready = join(directory, "ready");
|
||||
const stopped = join(directory, "stopped");
|
||||
const release = join(directory, "release");
|
||||
// Publish the signal by rename so the poller never reads a created but
|
||||
// still-empty file while the child is alive.
|
||||
const script = [
|
||||
'const fs = require("node:fs");',
|
||||
'for (const name of ["SIGINT", "SIGTERM"]) process.on(name, () => {',
|
||||
` fs.writeFileSync(${JSON.stringify(stopped)}, name);`,
|
||||
` fs.writeFileSync(${JSON.stringify(`${stopped}.partial`)}, name);`,
|
||||
` fs.renameSync(${JSON.stringify(`${stopped}.partial`)}, ${JSON.stringify(stopped)});`,
|
||||
` const exitCode = ${JSON.stringify(exitCode)};`,
|
||||
" if (exitCode !== null) process.exit(exitCode);",
|
||||
"});",
|
||||
|
||||
Reference in new issue
Block a user