mirror of
https://github.com/morluto/rea.git
synced 2026-11-25 13:48:44 +00:00
* perf(tests): supervise direct vitest scripts through run-exclusive on POSIX test:run, test:with-build, test:boundary, test:mcp, test:acceptance, test:integration, test:coverage and test:verbose invoked vitest directly, so an interrupted run could orphan detached provider children outside the owned process group. They now go through scripts/run-vitest.mjs, which wraps Vitest in run-exclusive --unlocked on non-Windows platforms (mirroring run-development-tests.mjs) and invokes Vitest directly on Windows, where source tests must not require the built Job Object artifact. Watch and CI shard scripts are unchanged. Refs #13357. Verified: launcher smoke run (4 tests passed), check:fast, knip. * fix(tests): forward stop signals from the vitest launcher to its child The launcher ignored SIGINT/SIGTERM when wrapped, so a signal sent only to its PID left Vitest and its descendants running. It now always forwards to the child (run-exclusive can only forward signals it receives itself) and reports the tracked signal's exit code (143/130) deterministically. Verified with a manual probe: SIGTERM to the launcher PID during a 60s fixture test exits 143 with the tree stopped; launcher smoke run passes. A nested-supervisor in-process test proved environmentally unstable (the inner Vitest main is killed under nested run-exclusive supervisors) and was not landed.
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { spawn } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
// Run Vitest under the owned process-group supervisor on POSIX so an
|
|
// interrupted run reaps detached provider children with the test tree.
|
|
// Windows source tests must not require the built Job Object artifact, so
|
|
// they invoke Vitest directly, as in run-development-tests.mjs.
|
|
const vitest = fileURLToPath(
|
|
new URL("../node_modules/vitest/vitest.mjs", import.meta.url),
|
|
);
|
|
const arguments_ = ["run", ...process.argv.slice(2)];
|
|
const wrap = process.platform !== "win32";
|
|
const child = spawn(
|
|
process.execPath,
|
|
wrap
|
|
? [
|
|
fileURLToPath(new URL("./run-exclusive.mjs", import.meta.url)),
|
|
"--unlocked",
|
|
process.execPath,
|
|
vitest,
|
|
...arguments_,
|
|
]
|
|
: [vitest, ...arguments_],
|
|
{ stdio: "inherit" },
|
|
);
|
|
|
|
const signalExitCodes = { SIGINT: 130, SIGTERM: 143 };
|
|
let receivedSignal;
|
|
for (const signal of Object.keys(signalExitCodes))
|
|
process.on(signal, () => {
|
|
// Forward even when wrapped: run-exclusive can only forward signals it
|
|
// receives itself, not ones delivered solely to this launcher PID.
|
|
receivedSignal ??= signal;
|
|
child.kill(signal);
|
|
});
|
|
|
|
child.once("error", (cause) => {
|
|
console.error(cause.message);
|
|
process.exitCode = 1;
|
|
});
|
|
child.once("close", (code, signal) => {
|
|
process.exitCode =
|
|
receivedSignal !== undefined
|
|
? signalExitCodes[receivedSignal]
|
|
: signal !== null && signal in signalExitCodes
|
|
? signalExitCodes[signal]
|
|
: (code ?? 1);
|
|
});
|