Skip to content

Commit 520a504

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 7a3c9bb commit 520a504

File tree

1 file changed

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

1 file changed

+37
-30
lines changed
+37-30
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
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 run_make_support::{cargo, run_in_tmpdir, rustc_path, source_root};
55

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

0 commit comments

Comments
 (0)