perf(test): trim background abort settle waits and dedupe cmd fixture

This commit is contained in:
Peter Steinberger
2026-02-22 09:40:22 +00:00
parent 7d13227d41
commit 2900eb5456

View File

@@ -7,6 +7,10 @@ import {
import { createExecTool } from "./bash-tools.exec.js";
import { killProcessTree } from "./shell-utils.js";
const BACKGROUND_HOLD_CMD = 'node -e "setTimeout(() => {}, 1000)"';
const ABORT_SETTLE_MS = process.platform === "win32" ? 200 : 60;
const ABORT_WAIT_TIMEOUT_MS = process.platform === "win32" ? 1_500 : 600;
afterEach(() => {
resetProcessRegistryForTests();
});
@@ -57,9 +61,9 @@ async function expectBackgroundSessionSurvivesAbort(params: {
() => {
const running = getSession(sessionId);
const finished = getFinishedSession(sessionId);
return Date.now() - startedAt >= 100 && !finished && running?.exited === false;
return Date.now() - startedAt >= ABORT_SETTLE_MS && !finished && running?.exited === false;
},
{ timeout: process.platform === "win32" ? 1_500 : 800, interval: 20 },
{ timeout: ABORT_WAIT_TIMEOUT_MS, interval: 20 },
)
.toBe(true);
@@ -102,7 +106,7 @@ test("background exec is not killed when tool signal aborts", async () => {
const tool = createExecTool({ allowBackground: true, backgroundMs: 0 });
await expectBackgroundSessionSurvivesAbort({
tool,
executeParams: { command: 'node -e "setTimeout(() => {}, 5000)"', background: true },
executeParams: { command: BACKGROUND_HOLD_CMD, background: true },
});
});
@@ -110,7 +114,7 @@ test("pty background exec is not killed when tool signal aborts", async () => {
const tool = createExecTool({ allowBackground: true, backgroundMs: 0 });
await expectBackgroundSessionSurvivesAbort({
tool,
executeParams: { command: 'node -e "setTimeout(() => {}, 5000)"', background: true, pty: true },
executeParams: { command: BACKGROUND_HOLD_CMD, background: true, pty: true },
});
});
@@ -119,7 +123,7 @@ test("background exec still times out after tool signal abort", async () => {
await expectBackgroundSessionTimesOut({
tool,
executeParams: {
command: 'node -e "setTimeout(() => {}, 5000)"',
command: BACKGROUND_HOLD_CMD,
background: true,
timeout: 0.2,
},
@@ -131,7 +135,7 @@ test("yielded background exec is not killed when tool signal aborts", async () =
const tool = createExecTool({ allowBackground: true, backgroundMs: 10 });
await expectBackgroundSessionSurvivesAbort({
tool,
executeParams: { command: 'node -e "setTimeout(() => {}, 5000)"', yieldMs: 5 },
executeParams: { command: BACKGROUND_HOLD_CMD, yieldMs: 5 },
});
});
@@ -140,7 +144,7 @@ test("yielded background exec still times out", async () => {
await expectBackgroundSessionTimesOut({
tool,
executeParams: {
command: 'node -e "setTimeout(() => {}, 5000)"',
command: BACKGROUND_HOLD_CMD,
yieldMs: 5,
timeout: 0.2,
},