@@ -14,11 +14,12 @@ use cargo::GlobalContext;
14
14
use cargo_test_support:: paths:: { self , CargoPathExt } ;
15
15
use cargo_test_support:: registry:: { Package , RegistryBuilder } ;
16
16
use cargo_test_support:: {
17
- basic_manifest, cargo_process, execs, git, project, retry, sleep_ms, thread_wait_timeout ,
18
- Project ,
17
+ basic_manifest, cargo_process, execs, git, process , project, retry, sleep_ms,
18
+ thread_wait_timeout , Execs , Project ,
19
19
} ;
20
20
use itertools:: Itertools ;
21
21
use std:: fmt:: Write ;
22
+ use std:: path:: Path ;
22
23
use std:: path:: PathBuf ;
23
24
use std:: process:: Stdio ;
24
25
use std:: time:: { Duration , SystemTime } ;
@@ -153,6 +154,14 @@ fn populate_cache(
153
154
( cache_dir, src_dir)
154
155
}
155
156
157
+ fn rustup_cargo ( ) -> Execs {
158
+ // Get the path to the rustup cargo wrapper. This is necessary because
159
+ // cargo adds the "deps" directory into PATH on Windows, which points to
160
+ // the wrong cargo.
161
+ let rustup_cargo = Path :: new ( & std:: env:: var_os ( "CARGO_HOME" ) . unwrap ( ) ) . join ( "bin/cargo" ) ;
162
+ execs ( ) . with_process_builder ( process ( rustup_cargo) )
163
+ }
164
+
156
165
#[ cargo_test]
157
166
fn auto_gc_gated ( ) {
158
167
// Requires -Zgc to both track last-use data and to run auto-gc.
@@ -1915,12 +1924,11 @@ fn compatible_with_older_cargo() {
1915
1924
middle = "1.0"
1916
1925
"# ,
1917
1926
) ;
1918
- p . process ( "cargo" )
1927
+ rustup_cargo ( )
1919
1928
. args ( & [ "+stable" , "check" , "-Zgc" ] )
1929
+ . cwd ( p. root ( ) )
1920
1930
. masquerade_as_nightly_cargo ( & [ "gc" ] )
1921
1931
. env ( "__CARGO_TEST_LAST_USE_NOW" , months_ago_unix ( 2 ) )
1922
- // Necessary since `process` removes rustup.
1923
- . env ( "PATH" , std:: env:: var_os ( "PATH" ) . unwrap ( ) )
1924
1932
. run ( ) ;
1925
1933
assert_eq ! ( get_registry_names( "src" ) , [ "middle-1.0.0" , "new-1.0.0" ] ) ;
1926
1934
assert_eq ! (
@@ -1978,11 +1986,10 @@ fn forward_compatible() {
1978
1986
. file ( "src/lib.rs" , "" )
1979
1987
. build ( ) ;
1980
1988
1981
- p . process ( "cargo" )
1989
+ rustup_cargo ( )
1982
1990
. args ( & [ "+stable" , "check" , "-Zgc" ] )
1991
+ . cwd ( p. root ( ) )
1983
1992
. masquerade_as_nightly_cargo ( & [ "gc" ] )
1984
- // Necessary since `process` removes rustup.
1985
- . env ( "PATH" , std:: env:: var_os ( "PATH" ) . unwrap ( ) )
1986
1993
. run ( ) ;
1987
1994
1988
1995
let config = GlobalContextBuilder :: new ( ) . unstable_flag ( "gc" ) . build ( ) ;
0 commit comments