Skip to content

Commit 4e53640

Browse files
committed
Pass the current cargo to run-make tests
A couple tests were using `BOOTSTRAP_CARGO` with `-Zbuild-std`, but that stage0 cargo might not always be in sync with in-tree changes. In particular, those tests started failing on the beta branch because the older cargo couldn't find the library `Cargo.lock`, and then couldn't build the latest version of `compiler_builtins` that had nightly changes.
1 parent 5ba6db1 commit 4e53640

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

src/bootstrap/src/core/build_steps/test.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,11 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17331733

17341734
let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
17351735

1736+
if mode == "run-make" {
1737+
let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
1738+
cmd.arg("--cargo-path").arg(cargo);
1739+
}
1740+
17361741
// Avoid depending on rustdoc when we don't need it.
17371742
if mode == "rustdoc"
17381743
|| mode == "run-make"

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ pub struct Config {
183183
/// The rustc executable.
184184
pub rustc_path: PathBuf,
185185

186+
/// The cargo executable.
187+
pub cargo_path: Option<PathBuf>,
188+
186189
/// The rustdoc executable.
187190
pub rustdoc_path: Option<PathBuf>,
188191

src/tools/compiletest/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
4747
opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
4848
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
4949
.reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH")
50+
.optopt("", "cargo-path", "path to cargo to use for compiling", "PATH")
5051
.optopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH")
5152
.optopt("", "coverage-dump-path", "path to coverage-dump to use in tests", "PATH")
5253
.reqopt("", "python", "path to python to use for doc tests", "PATH")
@@ -260,6 +261,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
260261
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
261262
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
262263
rustc_path: opt_path(matches, "rustc-path"),
264+
cargo_path: matches.opt_str("cargo-path").map(PathBuf::from),
263265
rustdoc_path: matches.opt_str("rustdoc-path").map(PathBuf::from),
264266
coverage_dump_path: matches.opt_str("coverage-dump-path").map(PathBuf::from),
265267
python: matches.opt_str("python").unwrap(),
@@ -364,6 +366,7 @@ pub fn log_config(config: &Config) {
364366
logv(c, format!("compile_lib_path: {:?}", config.compile_lib_path));
365367
logv(c, format!("run_lib_path: {:?}", config.run_lib_path));
366368
logv(c, format!("rustc_path: {:?}", config.rustc_path.display()));
369+
logv(c, format!("cargo_path: {:?}", config.cargo_path));
367370
logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path));
368371
logv(c, format!("src_base: {:?}", config.src_base.display()));
369372
logv(c, format!("build_base: {:?}", config.build_base.display()));

src/tools/compiletest/src/runtest/run_make.rs

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ impl TestCx<'_> {
6161
.env_remove("MFLAGS")
6262
.env_remove("CARGO_MAKEFLAGS");
6363

64+
if let Some(ref cargo) = self.config.cargo_path {
65+
cmd.env("CARGO", cwd.join(cargo));
66+
}
67+
6468
if let Some(ref rustdoc) = self.config.rustdoc_path {
6569
cmd.env("RUSTDOC", cwd.join(rustdoc));
6670
}
@@ -409,6 +413,10 @@ impl TestCx<'_> {
409413
// through a specific CI runner).
410414
.env("LLVM_COMPONENTS", &self.config.llvm_components);
411415

416+
if let Some(ref cargo) = self.config.cargo_path {
417+
cmd.env("CARGO", source_root.join(cargo));
418+
}
419+
412420
if let Some(ref rustdoc) = self.config.rustdoc_path {
413421
cmd.env("RUSTDOC", source_root.join(rustdoc));
414422
}

tests/run-make/compiler-builtins/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ fn main() {
3333

3434
let path = env_var("PATH");
3535
let rustc = env_var("RUSTC");
36-
let bootstrap_cargo = env_var("BOOTSTRAP_CARGO");
37-
let mut cmd = cmd(bootstrap_cargo);
36+
let cargo = env_var("CARGO");
37+
let mut cmd = cmd(cargo);
3838
cmd.args(&[
3939
"build",
4040
"--manifest-path",

tests/run-make/thumb-none-cortex-m/rmake.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ fn main() {
3636

3737
let path = env_var("PATH");
3838
let rustc = env_var("RUSTC");
39-
let bootstrap_cargo = env_var("BOOTSTRAP_CARGO");
40-
// FIXME: extract bootstrap cargo invocations to a proper command
39+
let cargo = env_var("CARGO");
40+
// FIXME: extract cargo invocations to a proper command
4141
// https://github.com/rust-lang/rust/issues/128734
42-
let mut cmd = cmd(bootstrap_cargo);
42+
let mut cmd = cmd(cargo);
4343
cmd.args(&[
4444
"build",
4545
"--manifest-path",

0 commit comments

Comments
 (0)