bootstrap: split run-make into {run-make,run-make-cargo} test suites

So that contributors who don't need to run `run-make` tests that require
in-tree `cargo` can run the non-cargo `run-make` tests without having to
wait for `cargo` (which would require rebuilding as the build cache
would be invalidated by compiler modifications without some kind of
`--keep-stage-cargo`).
This commit is contained in:
Jieyou Xu 2025-09-05 15:50:39 +08:00
parent c559c4a741
commit 0f76784d72
No known key found for this signature in database
GPG key ID: 045B995028EA6AFC
3 changed files with 80 additions and 21 deletions

View file

@ -1522,6 +1522,12 @@ test!(Pretty {
});
test!(RunMake { path: "tests/run-make", mode: "run-make", suite: "run-make", default: true });
test!(RunMakeCargo {
path: "tests/run-make-cargo",
mode: "run-make",
suite: "run-make-cargo",
default: true
});
test!(AssemblyLlvm {
path: "tests/assembly-llvm",
@ -1773,7 +1779,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
target,
});
}
if suite == "run-make" {
if mode == "run-make" {
builder.tool_exe(Tool::RunMakeSupport);
}
@ -1816,25 +1822,41 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
let is_rustdoc = suite == "rustdoc-ui" || suite == "rustdoc-js";
// There are (potentially) 2 `cargo`s to consider:
//
// - A "bootstrap" cargo, which is the same cargo used to build bootstrap itself, and is
// used to build the `run-make` test recipes and the `run-make-support` test library. All
// of these may not use unstable rustc/cargo features.
// - An in-tree cargo, which should be considered as under test. The `run-make-cargo` test
// suite is intended to support the use case of testing the "toolchain" (that is, at the
// minimum the interaction between in-tree cargo + rustc) together.
//
// For build time and iteration purposes, we partition `run-make` tests which needs an
// in-tree cargo (a smaller subset) versus `run-make` tests that do not into two test
// suites, `run-make` and `run-make-cargo`. That way, contributors who do not need to run
// the `run-make` tests that need in-tree cargo do not need to spend time building in-tree
// cargo.
if mode == "run-make" {
let cargo_path = if test_compiler.stage == 0 {
// If we're using `--stage 0`, we should provide the bootstrap cargo.
builder.initial_cargo.clone()
} else {
builder
.ensure(tool::Cargo::from_build_compiler(
builder.compiler(test_compiler.stage - 1, test_compiler.host),
test_compiler.host,
))
.tool_path
};
cmd.arg("--cargo-path").arg(cargo_path);
// We need to pass the compiler that was used to compile run-make-support,
// because we have to use the same compiler to compile rmake.rs recipes.
let stage0_rustc_path = builder.compiler(0, test_compiler.host);
cmd.arg("--stage0-rustc-path").arg(builder.rustc(stage0_rustc_path));
if suite == "run-make-cargo" {
let cargo_path = if test_compiler.stage == 0 {
// If we're using `--stage 0`, we should provide the bootstrap cargo.
builder.initial_cargo.clone()
} else {
builder
.ensure(tool::Cargo::from_build_compiler(
builder.compiler(test_compiler.stage - 1, test_compiler.host),
test_compiler.host,
))
.tool_path
};
cmd.arg("--cargo-path").arg(cargo_path);
}
}
// Avoid depending on rustdoc when we don't need it.

View file

@ -444,6 +444,7 @@ const PATH_REMAP: &[(&str, &[&str])] = &[
"tests/mir-opt",
"tests/pretty",
"tests/run-make",
"tests/run-make-cargo",
"tests/rustdoc",
"tests/rustdoc-gui",
"tests/rustdoc-js",
@ -1127,8 +1128,8 @@ impl<'a> Builder<'a> {
test::RustInstaller,
test::TestFloatParse,
test::CollectLicenseMetadata,
// Run run-make last, since these won't pass without make on Windows
test::RunMake,
test::RunMakeCargo,
),
Kind::Miri => describe!(test::Crate),
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),

View file

@ -2099,8 +2099,9 @@ mod snapshot {
[build] rustc 0 <host> -> HtmlChecker 1 <host>
[test] html-check <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 0 <host> -> cargo 1 <host>
[test] compiletest-run-make 1 <host>
[build] rustc 0 <host> -> cargo 1 <host>
[test] compiletest-run-make-cargo 1 <host>
");
}
@ -2118,7 +2119,6 @@ mod snapshot {
[test] compiletest-ui 1 <host>
[test] compiletest-ui-fulldeps 1 <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 0 <host> -> cargo 1 <host>
[build] rustdoc 1 <host>
[test] compiletest-run-make 1 <host>
[test] compiletest-rustdoc 1 <host>
@ -2147,7 +2147,6 @@ mod snapshot {
[build] rustc 2 <host> -> rustc 3 <host>
[test] compiletest-ui-fulldeps 2 <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 1 <host> -> cargo 2 <host>
[build] rustdoc 2 <host>
[test] compiletest-run-make 2 <host>
[test] compiletest-rustdoc 2 <host>
@ -2181,7 +2180,6 @@ mod snapshot {
[build] rustc 2 <host> -> rustc 3 <target1>
[test] compiletest-ui-fulldeps 2 <target1>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 1 <host> -> cargo 2 <host>
[build] rustdoc 2 <host>
[test] compiletest-run-make 2 <target1>
[test] compiletest-rustdoc 2 <target1>
@ -2276,8 +2274,9 @@ mod snapshot {
[build] rustc 0 <host> -> HtmlChecker 1 <host>
[test] html-check <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 1 <host> -> cargo 2 <host>
[test] compiletest-run-make 2 <host>
[build] rustc 1 <host> -> cargo 2 <host>
[test] compiletest-run-make-cargo 2 <host>
");
}
@ -2411,6 +2410,43 @@ mod snapshot {
");
}
// Differential snapshots for `./x test run-make` run `./x test run-make-cargo`: only
// `run-make-cargo` should build an in-tree cargo, running `./x test run-make` should not.
#[test]
fn test_run_make_no_cargo() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("test")
.path("run-make")
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 0 <host> -> Compiletest 1 <host>
[build] rustdoc 1 <host>
[test] compiletest-run-make 1 <host>
");
}
#[test]
fn test_run_make_cargo_builds_cargo() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("test")
.path("run-make-cargo")
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 0 <host> -> Compiletest 1 <host>
[build] rustc 0 <host> -> cargo 1 <host>
[build] rustdoc 1 <host>
[test] compiletest-run-make-cargo 1 <host>
");
}
#[test]
fn doc_all() {
let ctx = TestCtx::new();