@@ -138,6 +138,13 @@ struct Opts {
138
138
139
139
#[ structopt( long = "force-install" , help = "force installation over existing artifacts" ) ]
140
140
force_install : bool ,
141
+
142
+ #[ structopt(
143
+ long = "script" ,
144
+ help = "script to run instead of cargo to test for regression" ,
145
+ parse( from_os_str)
146
+ ) ]
147
+ script : Option < PathBuf > ,
141
148
}
142
149
143
150
#[ derive( Clone , Debug ) ]
@@ -443,7 +450,7 @@ impl Toolchain {
443
450
fn test ( & self , cfg : & Config , dl_spec : & DownloadParams ) -> TestOutcome {
444
451
if cfg. args . prompt {
445
452
loop {
446
- let status = self . run_cargo ( cfg, dl_spec) ;
453
+ let status = self . run_test ( cfg, dl_spec) ;
447
454
448
455
eprintln ! ( "\n \n {} finished with exit code {:?}." , self , status. code( ) ) ;
449
456
eprintln ! ( "please select an action to take:" ) ;
@@ -461,42 +468,50 @@ impl Toolchain {
461
468
}
462
469
}
463
470
} else {
464
- if self . run_cargo ( cfg, dl_spec) . success ( ) {
471
+ if self . run_test ( cfg, dl_spec) . success ( ) {
465
472
TestOutcome :: Baseline
466
473
} else {
467
474
TestOutcome :: Regressed
468
475
}
469
476
}
470
477
}
471
478
472
- fn run_cargo ( & self , cfg : & Config , dl_spec : & DownloadParams ) -> process:: ExitStatus {
473
- // do things with this toolchain
474
- let mut cargo = Command :: new ( "cargo" ) ;
475
- cargo. arg ( & format ! ( "+{}" , self . rustup_name( ) ) ) ;
476
- cargo. current_dir ( & cfg. args . test_dir ) ;
479
+ fn run_test ( & self , cfg : & Config , dl_spec : & DownloadParams ) -> process:: ExitStatus {
477
480
let _ = fs:: remove_dir_all (
478
481
cfg. args
479
482
. test_dir
480
483
. join ( & format ! ( "target-{}" , self . rustup_name( ) ) ) ,
481
484
) ;
482
- cargo. env ( "CARGO_TARGET_DIR" , format ! ( "target-{}" , self . rustup_name( ) ) ) ;
483
-
484
- if cfg. args . cargo_args . is_empty ( ) {
485
- cargo. arg ( "build" ) ;
486
- } else {
487
- cargo. args ( & cfg. args . cargo_args ) ;
488
- }
485
+ let mut cmd = match cfg. args . script {
486
+ Some ( ref script) => {
487
+ let mut cmd = Command :: new ( script) ;
488
+ cmd. env ( "RUSTUP_TOOLCHAIN" , self . rustup_name ( ) ) ;
489
+ cmd
490
+ }
491
+ None => {
492
+ let mut cmd = Command :: new ( "cargo" ) ;
493
+ cmd. arg ( & format ! ( "+{}" , self . rustup_name( ) ) ) ;
494
+ if cfg. args . cargo_args . is_empty ( ) {
495
+ cmd. arg ( "build" ) ;
496
+ } else {
497
+ cmd. args ( & cfg. args . cargo_args ) ;
498
+ }
499
+ cmd
500
+ }
501
+ } ;
502
+ cmd. current_dir ( & cfg. args . test_dir ) ;
503
+ cmd. env ( "CARGO_TARGET_DIR" , format ! ( "target-{}" , self . rustup_name( ) ) ) ;
489
504
if cfg. args . emit_cargo_output ( ) || cfg. args . prompt {
490
- cargo . stdout ( Stdio :: inherit ( ) ) ;
491
- cargo . stderr ( Stdio :: inherit ( ) ) ;
505
+ cmd . stdout ( Stdio :: inherit ( ) ) ;
506
+ cmd . stderr ( Stdio :: inherit ( ) ) ;
492
507
} else {
493
- cargo . stdout ( Stdio :: null ( ) ) ;
494
- cargo . stderr ( Stdio :: null ( ) ) ;
508
+ cmd . stdout ( Stdio :: null ( ) ) ;
509
+ cmd . stderr ( Stdio :: null ( ) ) ;
495
510
}
496
- let status = match cargo . status ( ) {
511
+ let status = match cmd . status ( ) {
497
512
Ok ( status) => status,
498
513
Err ( err) => {
499
- panic ! ( "failed to run {:?}: {:?}" , cargo , err) ;
514
+ panic ! ( "failed to run {:?}: {:?}" , cmd , err) ;
500
515
}
501
516
} ;
502
517
if !cfg. args . preserve {
0 commit comments