@@ -317,14 +317,15 @@ impl Toolchain {
317
317
. join ( & format ! ( "target-{}" , self . rustup_name( ) ) ) ,
318
318
) ;
319
319
}
320
- let mut cmd = match cfg. args . script {
321
- Some ( ref script) => {
320
+
321
+ let mut cmd = match ( cfg. args . script . as_ref ( ) , cfg. args . timeout ) {
322
+ ( Some ( script) , None ) => {
322
323
let mut cmd = Command :: new ( script) ;
323
324
cmd. env ( "RUSTUP_TOOLCHAIN" , self . rustup_name ( ) ) ;
324
325
cmd. args ( & cfg. args . command_args ) ;
325
326
cmd
326
327
}
327
- None => {
328
+ ( None , None ) => {
328
329
let mut cmd = Command :: new ( "cargo" ) ;
329
330
cmd. arg ( & format ! ( "+{}" , self . rustup_name( ) ) ) ;
330
331
if cfg. args . command_args . is_empty ( ) {
@@ -334,6 +335,26 @@ impl Toolchain {
334
335
}
335
336
cmd
336
337
}
338
+ ( Some ( script) , Some ( timeout) ) => {
339
+ let mut cmd = Command :: new ( "timeout" ) ;
340
+ cmd. arg ( timeout. to_string ( ) ) ;
341
+ cmd. arg ( script) ;
342
+ cmd. args ( & cfg. args . command_args ) ;
343
+ cmd. env ( "RUSTUP_TOOLCHAIN" , self . rustup_name ( ) ) ;
344
+ cmd
345
+ }
346
+ ( None , Some ( timeout) ) => {
347
+ let mut cmd = Command :: new ( "timeout" ) ;
348
+ cmd. arg ( timeout. to_string ( ) ) ;
349
+ cmd. arg ( "cargo" ) ;
350
+ cmd. arg ( format ! ( "+{}" , self . rustup_name( ) ) ) ;
351
+ if cfg. args . command_args . is_empty ( ) {
352
+ cmd. arg ( "build" ) ;
353
+ } else {
354
+ cmd. args ( & cfg. args . command_args ) ;
355
+ }
356
+ cmd
357
+ }
337
358
} ;
338
359
cmd. current_dir ( & cfg. args . test_dir ) ;
339
360
cmd. env ( "CARGO_TARGET_DIR" , format ! ( "target-{}" , self . rustup_name( ) ) ) ;
@@ -377,6 +398,14 @@ impl Toolchain {
377
398
let output = self . run_test ( cfg) ;
378
399
let status = output. status ;
379
400
401
+ //timeout returns exit code 124 on expiration
402
+ if status. code ( ) == Some ( 124 ) {
403
+ match cfg. args . timeout {
404
+ Some ( _) => break TestOutcome :: Regressed ,
405
+ None => panic ! ( "Process timed out but no timeout was specified. Please check host configuration for timeouts and try again." )
406
+ }
407
+ }
408
+
380
409
eprintln ! ( "\n \n {} finished with exit code {:?}." , self , status. code( ) ) ;
381
410
eprintln ! ( "please select an action to take:" ) ;
382
411
0 commit comments