Skip to content

Commit 84e50fc

Browse files
committed
test: preserve CLI process timeout diagnostics
1 parent 258418d commit 84e50fc

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

‎src/cli/help-exit.process.test.ts‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ import { pathToFileURL } from "node:url";
77
import { Command, CommanderError } from "commander";
88
import { afterEach, describe, expect, it } from "vitest";
99
import { useAutoCleanupTempDirTracker } from "../../test/helpers/temp-dir.js";
10+
import { DEFAULT_VITEST_TEST_TIMEOUT_MS } from "../../test/vitest/vitest.timeouts.js";
1011
import { registerCoreCliByName } from "./program/command-registry.js";
1112
import { createProgramContext } from "./program/context.js";
1213
import { registerSubCliByName } from "./program/register.subclis.js";
1314

1415
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
1516
// This is a deadlock guard, not a startup SLO. Fork CI can take over a minute
1617
// to cold-load the CLI graph on shared hosted runners, while still exiting correctly.
17-
const CHILD_PROCESS_TIMEOUT_MS = 240_000;
18-
const CHILD_PROCESS_TEST_TIMEOUT_MS = CHILD_PROCESS_TIMEOUT_MS + 10_000;
18+
// Keep the default guard below the shared Vitest deadline so it always reports
19+
// captured child output before the framework can replace it with an opaque timeout.
20+
const DEFAULT_CHILD_PROCESS_TIMEOUT_MS = DEFAULT_VITEST_TEST_TIMEOUT_MS - 20_000;
21+
const SLOW_DOTENV_CHILD_PROCESS_TIMEOUT_MS = 240_000;
22+
const SLOW_DOTENV_TEST_TIMEOUT_MS = SLOW_DOTENV_CHILD_PROCESS_TIMEOUT_MS + 10_000;
1923
const LAZY_GROUP_HELP_CASES = [
2024
{ group: "backup", usageCommand: "backup", registry: "core" },
2125
{ group: "capability", usageCommand: "infer|capability", registry: "subcli" },
@@ -139,6 +143,7 @@ async function runCliProcess(params: {
139143
loggingViaInclude?: boolean;
140144
loggingViaRootInclude?: boolean;
141145
stateEnv?: (stateDir: string) => Record<string, string>;
146+
timeoutMs?: number;
142147
}) {
143148
const fixture = await createHelpProcessFixture(
144149
params.config,
@@ -178,7 +183,7 @@ async function runCliProcess(params: {
178183
// CI shard runners export NODE_COMPILE_CACHE; in a source checkout entry.ts
179184
// then respawns a detached grandchild that shares this child's stdio pipes.
180185
// If the deadlock guard SIGKILLs the parent, the orphan keeps the pipes open
181-
// and execFile never settles, turning any slow child into a blind vitest
186+
// and the process wait never settles, turning any slow child into a blind vitest
182187
// timeout with no diagnostics. Keep these children single-process; the
183188
// compile-cache respawn contract has dedicated entry.compile-cache coverage.
184189
NODE_DISABLE_COMPILE_CACHE: "1",
@@ -225,7 +230,7 @@ async function runCliProcess(params: {
225230
stdout,
226231
}),
227232
);
228-
}, CHILD_PROCESS_TIMEOUT_MS);
233+
}, params.timeoutMs ?? DEFAULT_CHILD_PROCESS_TIMEOUT_MS);
229234
timeout.unref();
230235
}),
231236
]).finally(() => {
@@ -645,7 +650,7 @@ describe("JSON console style process output", () => {
645650
});
646651

647652
it(
648-
"loads dotenv before formatting entry validation diagnostics",
653+
"captures exact exit code 2 after loading dotenv for entry validation diagnostics",
649654
async () => {
650655
let failure: CliProcessFailure | undefined;
651656
try {
@@ -659,6 +664,7 @@ describe("JSON console style process output", () => {
659664
},
660665
env: { OPENCLAW_TEST_CONSOLE_STYLE: undefined },
661666
stateEnv: () => ({ OPENCLAW_TEST_CONSOLE_STYLE: "json" }),
667+
timeoutMs: SLOW_DOTENV_CHILD_PROCESS_TIMEOUT_MS,
662668
});
663669
} catch (error) {
664670
failure = error as CliProcessFailure;
@@ -672,7 +678,7 @@ describe("JSON console style process output", () => {
672678
}),
673679
]);
674680
},
675-
CHILD_PROCESS_TEST_TIMEOUT_MS,
681+
SLOW_DOTENV_TEST_TIMEOUT_MS,
676682
);
677683

678684
it("loads eligible dotenv before formatting a run-main import failure", async () => {

‎test/vitest/vitest.shared.config.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
} from "./vitest.bundled-plugin-paths.ts";
2323
import { loadVitestExperimentalConfig } from "./vitest.performance-config.ts";
2424
import { shouldPrintVitestThrottle } from "./vitest.system-load.ts";
25+
import { DEFAULT_VITEST_TEST_TIMEOUT_MS } from "./vitest.timeouts.ts";
2526

2627
export type OpenClawVitestPool = "forks" | "threads";
2728

@@ -555,7 +556,7 @@ export const sharedVitestConfig = {
555556
},
556557
test: {
557558
dir: repoRoot,
558-
testTimeout: 120_000,
559+
testTimeout: DEFAULT_VITEST_TEST_TIMEOUT_MS,
559560
hookTimeout: isWindows ? 180_000 : 120_000,
560561
unstubEnvs: true,
561562
unstubGlobals: true,

‎test/vitest/vitest.timeouts.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const DEFAULT_VITEST_TEST_TIMEOUT_MS = 120_000;

0 commit comments

Comments
 (0)