Skip to content

Commit 0f76784

Browse files
committed
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`).
1 parent c559c4a commit 0f76784

File tree

3 files changed

+80
-21
lines changed

3 files changed

+80
-21
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,12 @@ test!(Pretty {
15221522
});
15231523

15241524
test!(RunMake { path: "tests/run-make", mode: "run-make", suite: "run-make", default: true });
1525+
test!(RunMakeCargo {
1526+
path: "tests/run-make-cargo",
1527+
mode: "run-make",
1528+
suite: "run-make-cargo",
1529+
default: true
1530+
});
15251531

15261532
test!(AssemblyLlvm {
15271533
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
17731779
target,
17741780
});
17751781
}
1776-
if suite == "run-make" {
1782+
if mode == "run-make" {
17771783
builder.tool_exe(Tool::RunMakeSupport);
17781784
}
17791785

@@ -1816,25 +1822,41 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18161822

18171823
let is_rustdoc = suite == "rustdoc-ui" || suite == "rustdoc-js";
18181824

1825+
// There are (potentially) 2 `cargo`s to consider:
1826+
//
1827+
// - A "bootstrap" cargo, which is the same cargo used to build bootstrap itself, and is
1828+
// used to build the `run-make` test recipes and the `run-make-support` test library. All
1829+
// of these may not use unstable rustc/cargo features.
1830+
// - An in-tree cargo, which should be considered as under test. The `run-make-cargo` test
1831+
// suite is intended to support the use case of testing the "toolchain" (that is, at the
1832+
// minimum the interaction between in-tree cargo + rustc) together.
1833+
//
1834+
// For build time and iteration purposes, we partition `run-make` tests which needs an
1835+
// in-tree cargo (a smaller subset) versus `run-make` tests that do not into two test
1836+
// suites, `run-make` and `run-make-cargo`. That way, contributors who do not need to run
1837+
// the `run-make` tests that need in-tree cargo do not need to spend time building in-tree
1838+
// cargo.
18191839
if mode == "run-make" {
1820-
let cargo_path = if test_compiler.stage == 0 {
1821-
// If we're using `--stage 0`, we should provide the bootstrap cargo.
1822-
builder.initial_cargo.clone()
1823-
} else {
1824-
builder
1825-
.ensure(tool::Cargo::from_build_compiler(
1826-
builder.compiler(test_compiler.stage - 1, test_compiler.host),
1827-
test_compiler.host,
1828-
))
1829-
.tool_path
1830-
};
1831-
1832-
cmd.arg("--cargo-path").arg(cargo_path);
1833-
18341840
// We need to pass the compiler that was used to compile run-make-support,
18351841
// because we have to use the same compiler to compile rmake.rs recipes.
18361842
let stage0_rustc_path = builder.compiler(0, test_compiler.host);
18371843
cmd.arg("--stage0-rustc-path").arg(builder.rustc(stage0_rustc_path));
1844+
1845+
if suite == "run-make-cargo" {
1846+
let cargo_path = if test_compiler.stage == 0 {
1847+
// If we're using `--stage 0`, we should provide the bootstrap cargo.
1848+
builder.initial_cargo.clone()
1849+
} else {
1850+
builder
1851+
.ensure(tool::Cargo::from_build_compiler(
1852+
builder.compiler(test_compiler.stage - 1, test_compiler.host),
1853+
test_compiler.host,
1854+
))
1855+
.tool_path
1856+
};
1857+
1858+
cmd.arg("--cargo-path").arg(cargo_path);
1859+
}
18381860
}
18391861

18401862
// Avoid depending on rustdoc when we don't need it.

src/bootstrap/src/core/builder/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ const PATH_REMAP: &[(&str, &[&str])] = &[
444444
"tests/mir-opt",
445445
"tests/pretty",
446446
"tests/run-make",
447+
"tests/run-make-cargo",
447448
"tests/rustdoc",
448449
"tests/rustdoc-gui",
449450
"tests/rustdoc-js",
@@ -1127,8 +1128,8 @@ impl<'a> Builder<'a> {
11271128
test::RustInstaller,
11281129
test::TestFloatParse,
11291130
test::CollectLicenseMetadata,
1130-
// Run run-make last, since these won't pass without make on Windows
11311131
test::RunMake,
1132+
test::RunMakeCargo,
11321133
),
11331134
Kind::Miri => describe!(test::Crate),
11341135
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),

src/bootstrap/src/core/builder/tests.rs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,8 +2099,9 @@ mod snapshot {
20992099
[build] rustc 0 <host> -> HtmlChecker 1 <host>
21002100
[test] html-check <host>
21012101
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2102-
[build] rustc 0 <host> -> cargo 1 <host>
21032102
[test] compiletest-run-make 1 <host>
2103+
[build] rustc 0 <host> -> cargo 1 <host>
2104+
[test] compiletest-run-make-cargo 1 <host>
21042105
");
21052106
}
21062107

@@ -2118,7 +2119,6 @@ mod snapshot {
21182119
[test] compiletest-ui 1 <host>
21192120
[test] compiletest-ui-fulldeps 1 <host>
21202121
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2121-
[build] rustc 0 <host> -> cargo 1 <host>
21222122
[build] rustdoc 1 <host>
21232123
[test] compiletest-run-make 1 <host>
21242124
[test] compiletest-rustdoc 1 <host>
@@ -2147,7 +2147,6 @@ mod snapshot {
21472147
[build] rustc 2 <host> -> rustc 3 <host>
21482148
[test] compiletest-ui-fulldeps 2 <host>
21492149
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2150-
[build] rustc 1 <host> -> cargo 2 <host>
21512150
[build] rustdoc 2 <host>
21522151
[test] compiletest-run-make 2 <host>
21532152
[test] compiletest-rustdoc 2 <host>
@@ -2181,7 +2180,6 @@ mod snapshot {
21812180
[build] rustc 2 <host> -> rustc 3 <target1>
21822181
[test] compiletest-ui-fulldeps 2 <target1>
21832182
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2184-
[build] rustc 1 <host> -> cargo 2 <host>
21852183
[build] rustdoc 2 <host>
21862184
[test] compiletest-run-make 2 <target1>
21872185
[test] compiletest-rustdoc 2 <target1>
@@ -2276,8 +2274,9 @@ mod snapshot {
22762274
[build] rustc 0 <host> -> HtmlChecker 1 <host>
22772275
[test] html-check <host>
22782276
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2279-
[build] rustc 1 <host> -> cargo 2 <host>
22802277
[test] compiletest-run-make 2 <host>
2278+
[build] rustc 1 <host> -> cargo 2 <host>
2279+
[test] compiletest-run-make-cargo 2 <host>
22812280
");
22822281
}
22832282

@@ -2411,6 +2410,43 @@ mod snapshot {
24112410
");
24122411
}
24132412

2413+
// Differential snapshots for `./x test run-make` run `./x test run-make-cargo`: only
2414+
// `run-make-cargo` should build an in-tree cargo, running `./x test run-make` should not.
2415+
#[test]
2416+
fn test_run_make_no_cargo() {
2417+
let ctx = TestCtx::new();
2418+
insta::assert_snapshot!(
2419+
ctx.config("test")
2420+
.path("run-make")
2421+
.render_steps(), @r"
2422+
[build] llvm <host>
2423+
[build] rustc 0 <host> -> rustc 1 <host>
2424+
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2425+
[build] rustc 1 <host> -> std 1 <host>
2426+
[build] rustc 0 <host> -> Compiletest 1 <host>
2427+
[build] rustdoc 1 <host>
2428+
[test] compiletest-run-make 1 <host>
2429+
");
2430+
}
2431+
2432+
#[test]
2433+
fn test_run_make_cargo_builds_cargo() {
2434+
let ctx = TestCtx::new();
2435+
insta::assert_snapshot!(
2436+
ctx.config("test")
2437+
.path("run-make-cargo")
2438+
.render_steps(), @r"
2439+
[build] llvm <host>
2440+
[build] rustc 0 <host> -> rustc 1 <host>
2441+
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2442+
[build] rustc 1 <host> -> std 1 <host>
2443+
[build] rustc 0 <host> -> Compiletest 1 <host>
2444+
[build] rustc 0 <host> -> cargo 1 <host>
2445+
[build] rustdoc 1 <host>
2446+
[test] compiletest-run-make-cargo 1 <host>
2447+
");
2448+
}
2449+
24142450
#[test]
24152451
fn doc_all() {
24162452
let ctx = TestCtx::new();

0 commit comments

Comments
 (0)