@@ -7,15 +7,19 @@ import { pathToFileURL } from "node:url";
77import { Command , CommanderError } from "commander" ;
88import { afterEach , describe , expect , it } from "vitest" ;
99import { useAutoCleanupTempDirTracker } from "../../test/helpers/temp-dir.js" ;
10+ import { DEFAULT_VITEST_TEST_TIMEOUT_MS } from "../../test/vitest/vitest.timeouts.js" ;
1011import { registerCoreCliByName } from "./program/command-registry.js" ;
1112import { createProgramContext } from "./program/context.js" ;
1213import { registerSubCliByName } from "./program/register.subclis.js" ;
1314
1415const 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 ;
1923const 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 ( ) => {
0 commit comments