Skip to content

Commit 49b5c1f

Browse files
committed
run test in tmp dir and emit artifacts there
otherwise the test would build in the source root's `target` folder
1 parent c62fbdc commit 49b5c1f

File tree

1 file changed

+41
-30
lines changed
  • tests/run-make/rustc-crates-on-stable

1 file changed

+41
-30
lines changed
Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,47 @@
11
//! Checks if selected rustc crates can be compiled on the stable channel (or a "simulation" of it).
22
//! These crates are designed to be used by downstream users.
33
4-
use run_make_support::{cargo, rustc_path, source_root};
4+
use std::env::current_dir;
5+
6+
use run_make_support::{cargo, run_in_tmpdir, rustc_path, source_root};
57

68
fn main() {
7-
// Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we use)
8-
let cargo = cargo()
9-
// This is required to allow using nightly cargo features (public-dependency) with beta
10-
// cargo
11-
.env("RUSTC_BOOTSTRAP", "1")
12-
.env("RUSTC_STAGE", "0") // ensure `proc-macro2`'s nightly detection is disabled
13-
.env("RUSTC", rustc_path())
14-
.arg("build")
15-
.arg("--manifest-path")
16-
.arg(source_root().join("Cargo.toml"))
17-
.args(&[
18-
"--config",
19-
r#"workspace.exclude=["library/core"]"#,
20-
// We want to disallow all nightly features, to simulate a stable build
21-
// public-dependency needs to be enabled for cargo to work
22-
"-Zallow-features=public-dependency",
23-
// Avoid depending on transitive rustc crates
24-
"--no-default-features",
25-
// Check that these crates can be compiled on "stable"
26-
"-p",
27-
"rustc_type_ir",
28-
"-p",
29-
"rustc_next_trait_solver",
30-
"-p",
31-
"rustc_pattern_analysis",
32-
"-p",
33-
"rustc_lexer",
34-
])
35-
.run();
9+
run_in_tmpdir(|| {
10+
// Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we
11+
// use)
12+
let cargo = cargo()
13+
// Run from the current temporary directory and emit artifacts there, not in the
14+
// source_root's `target` folder
15+
.current_dir(current_dir().unwrap())
16+
// This is required to allow using nightly cargo features (public-dependency) with beta
17+
// cargo
18+
.env("RUSTC_BOOTSTRAP", "1")
19+
.env("RUSTC_STAGE", "0") // ensure `proc-macro2`'s nightly detection is disabled
20+
.env("RUSTC", rustc_path())
21+
.arg("build")
22+
.arg("--manifest-path")
23+
.arg(source_root().join("Cargo.toml"))
24+
.args(&[
25+
"--config",
26+
r#"workspace.exclude=["library/core"]"#,
27+
// We want to disallow all nightly features, to simulate a stable build
28+
// public-dependency needs to be enabled for cargo to work
29+
"-Zallow-features=public-dependency",
30+
// Avoid depending on transitive rustc crates
31+
"--no-default-features",
32+
// Emit artifacts in this temporary directory
33+
"--target-dir",
34+
".",
35+
// Check that these crates can be compiled on "stable"
36+
"-p",
37+
"rustc_type_ir",
38+
"-p",
39+
"rustc_next_trait_solver",
40+
"-p",
41+
"rustc_pattern_analysis",
42+
"-p",
43+
"rustc_lexer",
44+
])
45+
.run();
46+
});
3647
}

0 commit comments

Comments
 (0)