mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 17:23:37 +08:00
perf(tests): supervise direct vitest scripts through run-exclusive on POSIX (#14104)
* 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.
This commit is contained in:
+8
-8
@@ -161,24 +161,24 @@
|
||||
"scan:todos": "node scripts/scan-todos.mjs",
|
||||
"start": "node scripts/rea.mjs mcp",
|
||||
"test": "npm run test:with-build",
|
||||
"test:with-build": "npm run test:prepare && vitest run",
|
||||
"test:run": "vitest run",
|
||||
"test:with-build": "npm run test:prepare && node scripts/run-vitest.mjs",
|
||||
"test:run": "node scripts/run-vitest.mjs",
|
||||
"test:python": "python3 scripts/run-python-tests.py",
|
||||
"eval:mcp-catalog": "node scripts/run-exclusive.mjs artifacts python3 tests/support/analysis-efficiency/catalog-eval.py",
|
||||
"test:local": "node scripts/run-development-tests.mjs local",
|
||||
"test:fast": "node scripts/ci/test-group.mjs source",
|
||||
"test:built": "node scripts/ci/test-group.mjs built",
|
||||
"pretest:boundary": "npm run test:prepare",
|
||||
"test:boundary": "vitest run --project boundary --project cli-boundary --project process-boundary --project mcp-boundary --project process-global",
|
||||
"test:boundary": "node scripts/run-vitest.mjs --project boundary --project cli-boundary --project process-boundary --project mcp-boundary --project process-global",
|
||||
"pretest:mcp": "node scripts/check-dependency-install.mjs && node scripts/run-exclusive.mjs artifacts node scripts/run-turbo.mjs run artifacts:skills",
|
||||
"test:mcp": "vitest run --project mcp-boundary",
|
||||
"test:mcp": "node scripts/run-vitest.mjs --project mcp-boundary",
|
||||
"pretest:acceptance": "npm run build:cached",
|
||||
"test:acceptance": "vitest run --project acceptance",
|
||||
"test:acceptance": "node scripts/run-vitest.mjs --project acceptance",
|
||||
"test:changed": "node scripts/run-development-tests.mjs changed",
|
||||
"pretest:integration": "npm run test:prepare",
|
||||
"test:integration": "vitest run --project boundary --project cli-boundary --project process-boundary --project mcp-boundary --project process-global --project acceptance",
|
||||
"test:integration": "node scripts/run-vitest.mjs --project boundary --project cli-boundary --project process-boundary --project mcp-boundary --project process-global --project acceptance",
|
||||
"pretest:coverage": "npm run test:prepare",
|
||||
"test:coverage": "vitest run --coverage.enabled --coverage.provider=v8",
|
||||
"test:coverage": "node scripts/run-vitest.mjs --coverage.enabled --coverage.provider=v8",
|
||||
"test:coverage:reverse-tools": "vitest run --config vitest.reverse-tools.config.ts --coverage.enabled",
|
||||
"pretest:coverage:reverse-tools": "npm run test:prepare",
|
||||
"test:mutation:reverse-tools": "node scripts/prepare-reverse-tools-mutation.mjs && stryker run stryker.config.mjs && stryker run stryker.semantics.config.mjs",
|
||||
@@ -189,7 +189,7 @@
|
||||
"test:ci:shard:run": "vitest run --coverage.enabled --coverage.provider=v8 --coverage.thresholds.lines=0 --coverage.thresholds.functions=0 --coverage.thresholds.branches=0 --coverage.thresholds.statements=0 --reporter=default --reporter=blob",
|
||||
"test:ci:merge": "vitest --merge-reports --coverage.enabled --coverage.provider=v8",
|
||||
"pretest:verbose": "npm run test:prepare",
|
||||
"test:verbose": "vitest run --reporter=verbose",
|
||||
"test:verbose": "node scripts/run-vitest.mjs --reporter=verbose",
|
||||
"test:watch": "vitest --project domain --project services --project adapters --project composition --project conformance --project evaluation --changed",
|
||||
"pretest:watch:all": "npm run test:prepare",
|
||||
"test:watch:all": "vitest --changed",
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/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);
|
||||
});
|
||||
Reference in New Issue
Block a user