Skip to content

Commit 32c2630

Browse files
committed
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 #94829.
2 parents 7af9329 + a0de44f commit 32c2630

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

src/bootstrap/builder/tests.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
88
config.save_toolstates = None;
99
config.dry_run = true;
1010
config.ninja_in_file = false;
11-
config.out = PathBuf::from(env::var_os("BOOTSTRAP_OUTPUT_DIRECTORY").unwrap());
12-
config.initial_rustc = PathBuf::from(env::var_os("RUSTC").unwrap());
13-
config.initial_cargo = PathBuf::from(env::var_os("BOOTSTRAP_INITIAL_CARGO").unwrap());
1411
// try to avoid spurious failures in dist where we create/delete each others file
15-
let dir = config
16-
.out
12+
// HACK: rather than pull in `tempdir`, use the one that cargo has conveniently created for us
13+
let dir = Path::new(env!("OUT_DIR"))
1714
.join("tmp-rustbuild-tests")
1815
.join(&thread::current().name().unwrap_or("unknown").replace(":", "-"));
1916
t!(fs::create_dir_all(&dir));

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl Build {
454454
.map(PathBuf::from)
455455
.unwrap_or_else(|_| src.join("target"));
456456
let bootstrap_out = workspace_target_dir.join("debug");
457-
if !bootstrap_out.join("rustc").exists() {
457+
if !bootstrap_out.join("rustc").exists() && !cfg!(test) {
458458
// this restriction can be lifted whenever https://github.com/rust-lang/rfcs/pull/3028 is implemented
459459
panic!("run `cargo build --bins` before `cargo run`")
460460
}

src/bootstrap/test.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2368,10 +2368,6 @@ impl Step for Bootstrap {
23682368
.current_dir(builder.src.join("src/bootstrap"))
23692369
.env("RUSTFLAGS", "-Cdebuginfo=2")
23702370
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
2371-
// HACK: bootstrap's tests want to know the output directory, but there's no way to set
2372-
// it except through config.toml. Set it through an env variable instead.
2373-
.env("BOOTSTRAP_OUTPUT_DIRECTORY", &builder.config.out)
2374-
.env("BOOTSTRAP_INITIAL_CARGO", &builder.config.initial_cargo)
23752371
.env("RUSTC_BOOTSTRAP", "1")
23762372
.env("RUSTC", &builder.initial_rustc);
23772373
if let Some(flags) = option_env!("RUSTFLAGS") {

0 commit comments

Comments
 (0)