@@ -99,6 +99,9 @@ struct Opts {
99
99
#[ structopt( long = "preserve" , help = "Preserve the downloaded artifacts" ) ]
100
100
preserve : bool ,
101
101
102
+ #[ structopt( long = "preserve-target" , help = "Preserve the target directory used for builds" ) ]
103
+ preserve_target : bool ,
104
+
102
105
#[ structopt(
103
106
long = "with-cargo" , help = "Download cargo, by default the installed cargo is used"
104
107
) ]
@@ -459,9 +462,9 @@ impl Toolchain {
459
462
}
460
463
461
464
fn test ( & self , cfg : & Config , dl_spec : & DownloadParams ) -> TestOutcome {
462
- if cfg. args . prompt {
465
+ let outcome = if cfg. args . prompt {
463
466
loop {
464
- let status = self . run_test ( cfg, dl_spec ) ;
467
+ let status = self . run_test ( cfg) ;
465
468
466
469
eprintln ! ( "\n \n {} finished with exit code {:?}." , self , status. code( ) ) ;
467
470
eprintln ! ( "please select an action to take:" ) ;
@@ -479,20 +482,28 @@ impl Toolchain {
479
482
}
480
483
}
481
484
} else {
482
- if self . run_test ( cfg, dl_spec ) . success ( ) {
485
+ if self . run_test ( cfg) . success ( ) {
483
486
TestOutcome :: Baseline
484
487
} else {
485
488
TestOutcome :: Regressed
486
489
}
490
+ } ;
491
+
492
+ if !cfg. args . preserve {
493
+ let _ = self . remove ( dl_spec) ;
487
494
}
495
+
496
+ outcome
488
497
}
489
498
490
- fn run_test ( & self , cfg : & Config , dl_spec : & DownloadParams ) -> process:: ExitStatus {
491
- let _ = fs:: remove_dir_all (
492
- cfg. args
493
- . test_dir
494
- . join ( & format ! ( "target-{}" , self . rustup_name( ) ) ) ,
495
- ) ;
499
+ fn run_test ( & self , cfg : & Config ) -> process:: ExitStatus {
500
+ if !cfg. args . preserve_target {
501
+ let _ = fs:: remove_dir_all (
502
+ cfg. args
503
+ . test_dir
504
+ . join ( & format ! ( "target-{}" , self . rustup_name( ) ) ) ,
505
+ ) ;
506
+ }
496
507
let mut cmd = match cfg. args . script {
497
508
Some ( ref script) => {
498
509
let mut cmd = Command :: new ( script) ;
@@ -525,9 +536,6 @@ impl Toolchain {
525
536
panic ! ( "failed to run {:?}: {:?}" , cmd, err) ;
526
537
}
527
538
} ;
528
- if !cfg. args . preserve {
529
- let _ = self . remove ( dl_spec) ;
530
- }
531
539
532
540
status
533
541
}
0 commit comments