@@ -25,9 +25,11 @@ use cargo_test_support::{basic_manifest, paths, project, rustc_host, str, Execs}
2525use  std:: env; 
2626use  std:: path:: Path ; 
2727
28- fn  enable_build_std ( e :  & mut  Execs ,  arg :  Option < & str > )  { 
29-     e. env_remove ( "CARGO_HOME" ) ; 
30-     e. env_remove ( "HOME" ) ; 
28+ fn  enable_build_std ( e :  & mut  Execs ,  arg :  Option < & str > ,  isolated :  bool )  { 
29+     if  !isolated { 
30+         e. env_remove ( "CARGO_HOME" ) ; 
31+         e. env_remove ( "HOME" ) ; 
32+     } 
3133
3234    // And finally actually enable `build-std` for now 
3335    let  arg = match  arg { 
@@ -42,17 +44,23 @@ fn enable_build_std(e: &mut Execs, arg: Option<&str>) {
4244trait  BuildStd :  Sized  { 
4345    fn  build_std ( & mut  self )  -> & mut  Self ; 
4446    fn  build_std_arg ( & mut  self ,  arg :  & str )  -> & mut  Self ; 
47+     fn  build_std_isolated ( & mut  self )  -> & mut  Self ; 
4548    fn  target_host ( & mut  self )  -> & mut  Self ; 
4649} 
4750
4851impl  BuildStd  for  Execs  { 
4952    fn  build_std ( & mut  self )  -> & mut  Self  { 
50-         enable_build_std ( self ,  None ) ; 
53+         enable_build_std ( self ,  None ,   false ) ; 
5154        self 
5255    } 
5356
5457    fn  build_std_arg ( & mut  self ,  arg :  & str )  -> & mut  Self  { 
55-         enable_build_std ( self ,  Some ( arg) ) ; 
58+         enable_build_std ( self ,  Some ( arg) ,  false ) ; 
59+         self 
60+     } 
61+ 
62+     fn  build_std_isolated ( & mut  self )  -> & mut  Self  { 
63+         enable_build_std ( self ,  None ,  true ) ; 
5664        self 
5765    } 
5866
@@ -107,9 +115,12 @@ fn basic() {
107115        ) 
108116        . build ( ) ; 
109117
110-     p. cargo ( "check" ) . build_std ( ) . target_host ( ) . run ( ) ; 
118+     // An isolated CARGO_HOME environment is used elesewhere in this test 
119+     // to ensure no extra index updates is performed. 
120+     // It is achieve by asserting the complete stderr without any wildcard. 
121+     p. cargo ( "check" ) . build_std_isolated ( ) . target_host ( ) . run ( ) ; 
111122    p. cargo ( "build" ) 
112-         . build_std ( ) 
123+         . build_std_isolated ( ) 
113124        . target_host ( ) 
114125        // Importantly, this should not say [UPDATING] 
115126        // There have been multiple bugs where every build triggers and update. 
@@ -120,7 +131,7 @@ fn basic() {
120131"# ] ] ) 
121132        . run ( ) ; 
122133    p. cargo ( "run" ) 
123-         . build_std ( ) 
134+         . build_std_isolated ( ) 
124135        . target_host ( ) 
125136        . with_stderr_data ( str![ [ r#" 
126137[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s 
@@ -129,7 +140,7 @@ fn basic() {
129140"# ] ] ) 
130141        . run ( ) ; 
131142    p. cargo ( "test" ) 
132-         . build_std ( ) 
143+         . build_std_isolated ( ) 
133144        . target_host ( ) 
134145        . with_stderr_data ( str![ [ r#" 
135146[COMPILING] rustc-std-workspace-std [..] 
@@ -379,13 +390,11 @@ fn test_proc_macro() {
379390        . file ( "src/lib.rs" ,  "" ) 
380391        . build ( ) ; 
381392
382-     // Download dependencies first, 
383-     // so we can compare  `cargo test` output without any wildcard 
384-     p. cargo ( "fetch" ) . build_std ( ) . run ( ) ; 
385393    p. cargo ( "test --lib" ) 
386394        . env_remove ( cargo_util:: paths:: dylib_path_envvar ( ) ) 
387395        . build_std ( ) 
388396        . with_stderr_data ( str![ [ r#" 
397+ ... 
389398[COMPILING] foo v0.0.0 ([ROOT]/foo) 
390399[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s 
391400[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH]) 
0 commit comments