test(runtime): trim timer-heavy regression suites

This commit is contained in:
Peter Steinberger
2026-03-02 09:45:57 +00:00
parent fd4d157e45
commit 04030ddf68
4 changed files with 27 additions and 50 deletions

View File

@@ -6,8 +6,8 @@ import { withEnvAsync } from "../test-utils/env.js";
import { attachChildProcessBridge } from "./child-process-bridge.js";
import { runCommandWithTimeout, shouldSpawnWithShell } from "./exec.js";
const CHILD_READY_TIMEOUT_MS = 4_000;
const CHILD_EXIT_TIMEOUT_MS = 4_000;
const CHILD_READY_TIMEOUT_MS = 2_000;
const CHILD_EXIT_TIMEOUT_MS = 2_000;
function waitForLine(
stream: NodeJS.ReadableStream,
@@ -79,10 +79,10 @@ describe("runCommandWithTimeout", () => {
it("kills command when no output timeout elapses", async () => {
const result = await runCommandWithTimeout(
[process.execPath, "-e", "setTimeout(() => {}, 40)"],
[process.execPath, "-e", "setTimeout(() => {}, 80)"],
{
timeoutMs: 500,
noOutputTimeoutMs: 20,
noOutputTimeoutMs: 25,
},
);
@@ -101,24 +101,24 @@ describe("runCommandWithTimeout", () => {
"let count = 0;",
'const ticker = setInterval(() => { process.stdout.write(".");',
"count += 1;",
"if (count === 6) {",
"if (count === 3) {",
"clearInterval(ticker);",
"process.exit(0);",
"}",
"}, 25);",
"}, 15);",
].join(" "),
],
{
timeoutMs: 3_000,
// Keep a healthy margin above the emit interval while avoiding a 1s+ test delay.
noOutputTimeoutMs: 400,
// Keep a healthy margin above the emit interval while avoiding long idle waits.
noOutputTimeoutMs: 120,
},
);
expect(result.code ?? 0).toBe(0);
expect(result.termination).toBe("exit");
expect(result.noOutputTimedOut).toBe(false);
expect(result.stdout.length).toBeGreaterThanOrEqual(7);
expect(result.stdout.length).toBeGreaterThanOrEqual(4);
});
it("reports global timeout termination when overall timeout elapses", async () => {

View File

@@ -4,7 +4,7 @@ import { createProcessSupervisor } from "./supervisor.js";
type ProcessSupervisor = ReturnType<typeof createProcessSupervisor>;
type SpawnOptions = Parameters<ProcessSupervisor["spawn"]>[0];
type ChildSpawnOptions = Omit<Extract<SpawnOptions, { mode: "child" }>, "backendId" | "mode">;
const OUTPUT_DELAY_MS = 40;
const OUTPUT_DELAY_MS = 15;
async function spawnChild(supervisor: ProcessSupervisor, options: ChildSpawnOptions) {
return supervisor.spawn({
@@ -38,9 +38,9 @@ describe("process supervisor", () => {
const supervisor = createProcessSupervisor();
const run = await spawnChild(supervisor, {
sessionId: "s1",
argv: [process.execPath, "-e", "setTimeout(() => {}, 40)"],
argv: [process.execPath, "-e", "setTimeout(() => {}, 30)"],
timeoutMs: 500,
noOutputTimeoutMs: 20,
noOutputTimeoutMs: 12,
stdinMode: "pipe-closed",
});
const exit = await run.wait();
@@ -84,7 +84,7 @@ describe("process supervisor", () => {
const supervisor = createProcessSupervisor();
const run = await spawnChild(supervisor, {
sessionId: "s-timeout",
argv: [process.execPath, "-e", "setTimeout(() => {}, 40)"],
argv: [process.execPath, "-e", "setTimeout(() => {}, 20)"],
timeoutMs: 1,
stdinMode: "pipe-closed",
});