Files
reverse-engineering-anything/tests/acceptance/process/processSignalExit.test.ts
T
morluto 83ed1cbd2a test: let the suite own default test deadlines
178 Vitest cases set an explicit 30 s deadline, the old suite default.
An explicit per-test value overrides the suite setting, so these cases
kept 30 s under coverage (suite: 60 s) and on hosted CI (60 s since
#10417); asyncChunkCapacity.test.ts then timed out at 30 s on main.

Remove only explicit test or describe deadlines equal to 30 s, selected
by syntax tree. Hook deadlines, subprocess timeouts, setTimeout delays
and data values are unchanged. Local runs keep 30 s.
2026-11-13 16:26:35 -05:00

98 lines
3.2 KiB
TypeScript

import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect } from "vitest";
import { toolContract } from "../../../src/contracts/toolContracts.js";
import { parseEvidence } from "../../../src/domain/evidence.js";
import { parseProcessCapture } from "../../../src/domain/process/processCaptureParsing.js";
import { cliTest } from "../../support/cli/cliFixture.js";
import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import {
CAPTURE_SKIP_REASON,
itWithCaptureCapability as captureTest,
} from "../../boundary/process/processCaptureCapability.js";
const hang = ["-e", "setTimeout(() => {}, 5000)"];
const cliCaptureTest = cliTest.skipIf(CAPTURE_SKIP_REASON);
cliCaptureTest(
"records no normal exit code for a target a scenario signal terminated",
async ({ cli }) => {
const root = await createTestTempDirectory("rea-process-signal-exit-");
for (const [name, additions, expected] of [
[
"SIGKILL",
{ events: [{ type: "signal", at_ms: 200, signal: "SIGKILL" }] },
{ code: null, signal: 9, reason: "exited" },
],
[
"SIGTERM",
{ events: [{ type: "signal", at_ms: 200, signal: "SIGTERM" }] },
{ code: null, signal: 15, reason: "exited" },
],
[
"exit 3",
{ arguments: ["-e", "process.exit(3)"] },
{ code: 3, signal: 0, reason: "exited" },
],
[
"exit 0",
{ arguments: ["-e", "process.exit(0)"] },
{ code: 0, signal: 0, reason: "exited" },
],
["deadline", { timeout_ms: 300 }, { code: null, reason: "timeout" }],
] as const) {
const scenarioPath = join(root, `${name.replace(" ", "-")}.json`);
await writeFile(
scenarioPath,
JSON.stringify({
executable: process.execPath,
arguments: hang,
timeout_ms: 5_000,
settle_ms: 300,
...additions,
}),
);
const result = await cli.run({
arguments: ["capture-process", scenarioPath, "--format", "json"],
environment: process.env,
});
expect(result.exitCode, result.stderr).toBe(0);
expect(result.signal, result.stderr).toBeNull();
const capture = parseProcessCapture(
parseEvidence(result.json).normalized_result,
);
expect(capture.exit, name).toMatchObject(expected);
}
},
60_000,
);
captureTest(
"records no normal exit code for a signal-terminated target through MCP",
async () => {
const { call } = await connectLocalToolsMcp();
const response = await call("capture_process_scenario", {
executable: process.execPath,
arguments: hang,
timeout_ms: 5_000,
settle_ms: 300,
events: [{ type: "signal", at_ms: 200, signal: "SIGKILL" }],
});
expect(response.isError).not.toBe(true);
const capture = parseProcessCapture(
parseEvidence(
toolContract("capture_process_scenario").outputSchema.parse(
response.structuredContent,
),
).normalized_result,
);
expect(capture.exit).toMatchObject({
code: null,
signal: 9,
reason: "exited",
});
},
);