File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
crates/cargo-test-support/src Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -1064,11 +1064,27 @@ fn _process(t: &OsStr) -> ProcessBuilder {
10641064 if env:: var_os ( "RUSTUP_TOOLCHAIN" ) . is_some ( ) {
10651065 // Override the PATH to avoid executing the rustup wrapper thousands
10661066 // of times. This makes the testsuite run substantially faster.
1067+ lazy_static:: lazy_static! {
1068+ static ref RUSTC_DIR : PathBuf = {
1069+ match ProcessBuilder :: new( "rustup" )
1070+ . args( & [ "which" , "rustc" ] )
1071+ . exec_with_output( )
1072+ {
1073+ Ok ( output) => {
1074+ let s = str :: from_utf8( & output. stdout) . expect( "utf8" ) . trim( ) ;
1075+ let mut p = PathBuf :: from( s) ;
1076+ p. pop( ) ;
1077+ p
1078+ }
1079+ Err ( e) => {
1080+ panic!( "RUSTUP_TOOLCHAIN was set, but could not run rustup: {}" , e) ;
1081+ }
1082+ }
1083+ } ;
1084+ }
10671085 let path = env:: var_os ( "PATH" ) . unwrap_or_default ( ) ;
10681086 let paths = env:: split_paths ( & path) ;
1069- let mut outer_cargo = PathBuf :: from ( env:: var_os ( "CARGO" ) . unwrap ( ) ) ;
1070- outer_cargo. pop ( ) ;
1071- let new_path = env:: join_paths ( std:: iter:: once ( outer_cargo) . chain ( paths) ) . unwrap ( ) ;
1087+ let new_path = env:: join_paths ( std:: iter:: once ( RUSTC_DIR . clone ( ) ) . chain ( paths) ) . unwrap ( ) ;
10721088 p. env ( "PATH" , new_path) ;
10731089 }
10741090
You can’t perform that action at this time.
0 commit comments