diff options
| author | bors <bors@rust-lang.org> | 2022-04-10 12:30:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-10 12:30:26 +0000 |
| commit | 32c26302620b2dbbe0a2291f1969bc0b1622ae59 (patch) | |
| tree | 242faeeb79c16266a0664e74dfa50ff6f1523536 | |
| parent | 7af93292c27cd8b4a14f0f35bcb4c7e7ca9c287a (diff) | |
| parent | a0de44f469c22d10c3aada165ae6afd38d40ad2c (diff) | |
| download | rust-32c26302620b2dbbe0a2291f1969bc0b1622ae59.tar.gz rust-32c26302620b2dbbe0a2291f1969bc0b1622ae59.zip | |
Auto merge of #95253 - jyn514:cargo-run, r=Mark-Simulacrum
Make it possible to run `cargo test` for bootstrap Note that this only runs bootstrap's self-tests, not compiler or library tests. Helps with https://github.com/rust-lang/rust/issues/94829.
| -rw-r--r-- | src/bootstrap/builder/tests.rs | 7 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/test.rs | 4 |
3 files changed, 3 insertions, 10 deletions
diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index b76bb569852..a59f72ed968 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -8,12 +8,9 @@ fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config { config.save_toolstates = None; config.dry_run = true; config.ninja_in_file = false; - config.out = PathBuf::from(env::var_os("BOOTSTRAP_OUTPUT_DIRECTORY").unwrap()); - config.initial_rustc = PathBuf::from(env::var_os("RUSTC").unwrap()); - config.initial_cargo = PathBuf::from(env::var_os("BOOTSTRAP_INITIAL_CARGO").unwrap()); // try to avoid spurious failures in dist where we create/delete each others file - let dir = config - .out + // HACK: rather than pull in `tempdir`, use the one that cargo has conveniently created for us + let dir = Path::new(env!("OUT_DIR")) .join("tmp-rustbuild-tests") .join(&thread::current().name().unwrap_or("unknown").replace(":", "-")); t!(fs::create_dir_all(&dir)); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index b93fc791820..e4937d7bbcc 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -454,7 +454,7 @@ impl Build { .map(PathBuf::from) .unwrap_or_else(|_| src.join("target")); let bootstrap_out = workspace_target_dir.join("debug"); - if !bootstrap_out.join("rustc").exists() { + if !bootstrap_out.join("rustc").exists() && !cfg!(test) { // this restriction can be lifted whenever https://github.com/rust-lang/rfcs/pull/3028 is implemented panic!("run `cargo build --bins` before `cargo run`") } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 9d7ea09fc82..b88684791bc 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -2368,10 +2368,6 @@ impl Step for Bootstrap { .current_dir(builder.src.join("src/bootstrap")) .env("RUSTFLAGS", "-Cdebuginfo=2") .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) - // HACK: bootstrap's tests want to know the output directory, but there's no way to set - // it except through config.toml. Set it through an env variable instead. - .env("BOOTSTRAP_OUTPUT_DIRECTORY", &builder.config.out) - .env("BOOTSTRAP_INITIAL_CARGO", &builder.config.initial_cargo) .env("RUSTC_BOOTSTRAP", "1") .env("RUSTC", &builder.initial_rustc); if let Some(flags) = option_env!("RUSTFLAGS") { |
