File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
crates/cargo-test-support/src Expand file tree Collapse file tree 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 {
15821582 p. env_remove ( & k) ;
15831583 }
15841584 }
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+ }
15851595
15861596 p. cwd ( & paths:: root ( ) )
15871597 . env ( "HOME" , paths:: home ( ) )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ use semver::Version;
1919use std:: fs;
2020
2121fn tc_process ( cmd : & str , toolchain : & str ) -> ProcessBuilder {
22- if toolchain == "this" {
22+ let mut p = if toolchain == "this" {
2323 if cmd == "cargo" {
2424 process ( & cargo_exe ( ) )
2525 } else {
@@ -29,7 +29,10 @@ fn tc_process(cmd: &str, toolchain: &str) -> ProcessBuilder {
2929 let mut cmd = process ( cmd) ;
3030 cmd. arg ( format ! ( "+{}" , toolchain) ) ;
3131 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
3336}
3437
3538/// Returns a sorted list of all toolchains.
You can’t perform that action at this time.
0 commit comments