File tree 2 files changed +15
-2
lines changed
crates/cargo-test-support/src 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1582,6 +1582,16 @@ fn _process(t: &OsStr) -> cargo::util::ProcessBuilder {
1582
1582
p. env_remove ( & k) ;
1583
1583
}
1584
1584
}
1585
+ if env:: var_os ( "RUSTUP_TOOLCHAIN" ) . is_some ( ) {
1586
+ // Override the PATH to avoid executing the rustup wrapper thousands
1587
+ // of times. This makes the testsuite run substantially faster.
1588
+ let path = env:: var_os ( "PATH" ) . unwrap_or_default ( ) ;
1589
+ let paths = env:: split_paths ( & path) ;
1590
+ let mut outer_cargo = PathBuf :: from ( env:: var_os ( "CARGO" ) . unwrap ( ) ) ;
1591
+ outer_cargo. pop ( ) ;
1592
+ let new_path = env:: join_paths ( std:: iter:: once ( outer_cargo) . chain ( paths) ) . unwrap ( ) ;
1593
+ p. env ( "PATH" , new_path) ;
1594
+ }
1585
1595
1586
1596
p. cwd ( & paths:: root ( ) )
1587
1597
. env ( "HOME" , paths:: home ( ) )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ use semver::Version;
19
19
use std:: fs;
20
20
21
21
fn tc_process ( cmd : & str , toolchain : & str ) -> ProcessBuilder {
22
- if toolchain == "this" {
22
+ let mut p = if toolchain == "this" {
23
23
if cmd == "cargo" {
24
24
process ( & cargo_exe ( ) )
25
25
} else {
@@ -29,7 +29,10 @@ fn tc_process(cmd: &str, toolchain: &str) -> ProcessBuilder {
29
29
let mut cmd = process ( cmd) ;
30
30
cmd. arg ( format ! ( "+{}" , toolchain) ) ;
31
31
cmd
32
- }
32
+ } ;
33
+ // Reset PATH since `process` modifies it to remove rustup.
34
+ p. env ( "PATH" , std:: env:: var_os ( "PATH" ) . unwrap ( ) ) ;
35
+ p
33
36
}
34
37
35
38
/// Returns a sorted list of all toolchains.
You can’t perform that action at this time.
0 commit comments