Skip to content

Commit 95e8b1c

Browse files
committed
Fix compatible_with_older_cargo test.
1 parent e98f702 commit 95e8b1c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tests/testsuite/global_cache_tracker.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use cargo_test_support::{
2020
thread_wait_timeout, Execs, Project,
2121
};
2222
use itertools::Itertools;
23+
use std::env;
2324
use std::fmt::Write;
2425
use std::path::Path;
2526
use std::path::PathBuf;
@@ -169,12 +170,19 @@ fn populate_cache(
169170
(cache_dir, src_dir)
170171
}
171172

173+
/// Returns an `Execs` that will run the rustup `cargo` proxy from the global
174+
/// system's cargo home directory.
172175
fn rustup_cargo() -> Execs {
173-
// Get the path to the rustup cargo wrapper. This is necessary because
174-
// cargo adds the "deps" directory into PATH on Windows, which points to
175-
// the wrong cargo.
176-
let rustup_cargo = Path::new(&std::env::var_os("CARGO_HOME").unwrap()).join("bin/cargo");
177-
execs().with_process_builder(process(rustup_cargo))
176+
// Modify the PATH to ensure that `cargo` and `rustc` comes from
177+
// CARGO_HOME. This is necessary because cargo adds the "deps" directory
178+
// into PATH on Windows, which points to the wrong cargo.
179+
let real_cargo_home_bin = Path::new(&std::env::var_os("CARGO_HOME").unwrap()).join("bin");
180+
let mut paths = vec![real_cargo_home_bin];
181+
paths.extend(env::split_paths(&env::var_os("PATH").unwrap_or_default()));
182+
let path = env::join_paths(paths).unwrap();
183+
let mut e = execs().with_process_builder(process("cargo"));
184+
e.env("PATH", path);
185+
e
178186
}
179187

180188
#[cargo_test]

0 commit comments

Comments
 (0)