@@ -66,7 +66,7 @@ function runNpm(args, cwd, env = {}) {
6666 return run ( npm . command , [ ...npm . prefixArgs , ...args ] , cwd , env ) ;
6767}
6868
69- function runProcess ( command , args , cwd , env = { } ) {
69+ function runProcess ( command , args , cwd , env = { } , timeoutMs = 120_000 ) {
7070 return new Promise ( ( resolve , reject ) => {
7171 const child = spawn ( command , args , {
7272 cwd,
@@ -76,14 +76,22 @@ function runProcess(command, args, cwd, env = {}) {
7676 } ) ;
7777 let stdout = "" ;
7878 let stderr = "" ;
79+ const timeout = setTimeout ( ( ) => {
80+ child . kill ( ) ;
81+ reject ( new Error ( `Process timed out after ${ timeoutMs } ms: ${ command } ${ args . join ( " " ) } \nstdout:\n${ stdout } \nstderr:\n${ stderr } ` ) ) ;
82+ } , timeoutMs ) ;
7983 child . stdout . on ( "data" , ( chunk ) => {
8084 stdout += chunk . toString ( "utf8" ) ;
8185 } ) ;
8286 child . stderr . on ( "data" , ( chunk ) => {
8387 stderr += chunk . toString ( "utf8" ) ;
8488 } ) ;
85- child . on ( "error" , reject ) ;
89+ child . on ( "error" , ( error ) => {
90+ clearTimeout ( timeout ) ;
91+ reject ( error ) ;
92+ } ) ;
8693 child . on ( "exit" , ( code , signal ) => {
94+ clearTimeout ( timeout ) ;
8795 resolve ( { code : code ?? 1 , signal, stdout, stderr } ) ;
8896 } ) ;
8997 } ) ;
@@ -315,6 +323,17 @@ async function assertInstalledDaemonUsesRustDefault(cliPath, repoDir, env) {
315323 const finalStatus = parseJsonCommand ( process . execPath , [ cliPath , "status" , "--json" ] , repoDir , env ) ;
316324 trace ( "daemon final status returned" ) ;
317325 assert . equal ( finalStatus . status . running , false ) ;
326+
327+ const humanStart = await runProcess ( process . execPath , [ cliPath , "start" , "--lang" , "en" ] , repoDir , env , 15_000 ) ;
328+ assert . equal (
329+ humanStart . code ,
330+ 0 ,
331+ `installed Rust human start should exit successfully when stdout is captured\nstdout:\n${ humanStart . stdout } \nstderr:\n${ humanStart . stderr } \n` +
332+ `diagnostics:\n${ JSON . stringify ( installedDaemonDiagnostics ( repoDir ) , null , 2 ) } `
333+ ) ;
334+ assert . match ( humanStart . stdout , / d a e m o n s t a r t e d / i) ;
335+ const humanStop = parseJsonCommand ( process . execPath , [ cliPath , "stop" , "--json" ] , repoDir , env ) ;
336+ assert . equal ( humanStop . ok , true ) ;
318337 } finally {
319338 try {
320339 run ( process . execPath , [ cliPath , "stop" , "--json" ] , repoDir , env ) ;
0 commit comments