File tree 1 file changed +19
-3
lines changed
crates/cargo-test-support/src
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 {
1064
1064
if env:: var_os ( "RUSTUP_TOOLCHAIN" ) . is_some ( ) {
1065
1065
// Override the PATH to avoid executing the rustup wrapper thousands
1066
1066
// 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
+ }
1067
1085
let path = env:: var_os ( "PATH" ) . unwrap_or_default ( ) ;
1068
1086
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 ( ) ;
1072
1088
p. env ( "PATH" , new_path) ;
1073
1089
}
1074
1090
You can’t perform that action at this time.
0 commit comments