@@ -321,4 +321,69 @@ describe("scripts/lib/openclaw-e2e-instance.sh", () => {
321321 fs . rmSync ( tempDir , { force : true , recursive : true } ) ;
322322 }
323323 } ) ;
324+
325+ it ( "wraps logged OpenClaw E2E commands with the configured timeout" , ( ) => {
326+ const tempDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-e2e-instance-run-logged-" ) ) ;
327+ const logLabel = path . basename ( tempDir ) ;
328+ const logPath = `/tmp/openclaw-onboard-${ logLabel } .log` ;
329+ try {
330+ const timeoutArgsPath = path . join ( tempDir , "timeout-args.txt" ) ;
331+ const commandArgsPath = path . join ( tempDir , "command-args.txt" ) ;
332+ fs . writeFileSync (
333+ path . join ( tempDir , "timeout" ) ,
334+ [
335+ "#!/usr/bin/env bash" ,
336+ "set -euo pipefail" ,
337+ 'printf "%s\\n" "$*" >"$OPENCLAW_TEST_TIMEOUT_ARGS"' ,
338+ 'while [ "$#" -gt 0 ] && [ "$1" != "fixture-command" ]; do shift; done' ,
339+ 'exec "$@"' ,
340+ "" ,
341+ ] . join ( "\n" ) ,
342+ ) ;
343+ fs . writeFileSync (
344+ path . join ( tempDir , "fixture-command" ) ,
345+ [
346+ "#!/usr/bin/env bash" ,
347+ "set -euo pipefail" ,
348+ 'printf "%s\\n" "$*" >"$OPENCLAW_TEST_COMMAND_ARGS"' ,
349+ 'printf "fixture output\\n"' ,
350+ "" ,
351+ ] . join ( "\n" ) ,
352+ ) ;
353+ fs . chmodSync ( path . join ( tempDir , "timeout" ) , 0o755 ) ;
354+ fs . chmodSync ( path . join ( tempDir , "fixture-command" ) , 0o755 ) ;
355+
356+ const result = spawnSync (
357+ "/bin/bash" ,
358+ [
359+ "-c" ,
360+ [
361+ "set -euo pipefail" ,
362+ `source ${ shellQuote ( helperPath ) } ` ,
363+ `openclaw_e2e_run_logged ${ shellQuote ( logLabel ) } fixture-command one two` ,
364+ ] . join ( "; " ) ,
365+ ] ,
366+ {
367+ encoding : "utf8" ,
368+ env : {
369+ ...process . env ,
370+ PATH : `${ tempDir } :${ process . env . PATH ?? "" } ` ,
371+ OPENCLAW_E2E_COMMAND_TIMEOUT : "17s" ,
372+ OPENCLAW_TEST_TIMEOUT_ARGS : timeoutArgsPath ,
373+ OPENCLAW_TEST_COMMAND_ARGS : commandArgsPath ,
374+ } ,
375+ } ,
376+ ) ;
377+
378+ expect ( result . status ) . toBe ( 0 ) ;
379+ expect ( fs . readFileSync ( timeoutArgsPath , "utf8" ) . trim ( ) ) . toBe (
380+ "--kill-after=30s 17s fixture-command one two" ,
381+ ) ;
382+ expect ( fs . readFileSync ( commandArgsPath , "utf8" ) . trim ( ) ) . toBe ( "one two" ) ;
383+ expect ( fs . readFileSync ( logPath , "utf8" ) ) . toContain ( "fixture output" ) ;
384+ } finally {
385+ fs . rmSync ( tempDir , { force : true , recursive : true } ) ;
386+ fs . rmSync ( logPath , { force : true } ) ;
387+ }
388+ } ) ;
324389} ) ;
0 commit comments