Skip to content

Commit 1ed3cd7

Browse files
committed
Auto merge of #146233 - jieyouxu:run-make-fission, r=Kobzol
Split `run-make` into two {`run-make`,`run-make-cargo`} test suites ## Summary Split `tests/run-make` into two test suites, to make it faster and more convenient for contributors to run run-make tests that do not need in-tree `cargo`. | New test suites | Explanation | | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `tests/run-make` | The "fast path" test suite intended for run-make tests that do not need in-tree `cargo`. These tests may not use `cargo`. | | `tests/run-make-cargo` | The "slow path" test suite that requires checking out `cargo` submodule and building in-tree `cargo`, and thus will have access to in-tree `cargo`. In practice, these constitute a very small portion of the original `run-make` tests. | This PR carries out [MCP 847: Split run-make test suite into slower-building test suite with suitably-staged cargo and faster-building test suite without cargo](rust-lang/compiler-team#847). Fixes #135573 (for the tests that do not need in-tree `cargo`). Fixes #134109. ## Remarks - I considered if we want to split by in-tree tools previously. However, as discussed #134109, in practice `rustdoc` is not very slow to build, but `cargo` takes a good few minutes. So, the partition boundary was determined to be along in-tree `cargo` availability. - The `run-make` tests previously that wanted to use `cargo` cannot just use the bootstrap `cargo`, otherwise they would run into situations where bootstrap `cargo` can significantly diverge from in-tree `cargo` (see #130642). --- try-job: aarch64-msvc-1 try-job: test-various try-job: x86_64-gnu-debug try-job: aarch64-gnu-debug try-job: aarch64-apple try-job: dist-various-1
2 parents bea625f + f755e64 commit 1ed3cd7

File tree

72 files changed

+177
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+177
-78
lines changed

compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ rm tests/ui/abi/large-byval-align.rs # exceeds implementation limit of Cranelift
121121
# ============================================================
122122
rm -r tests/run-make/remap-path-prefix-dwarf # requires llvm-dwarfdump
123123
rm -r tests/run-make/strip # same
124-
rm -r tests/run-make/compiler-builtins # Expects lib/rustlib/src/rust to contains the standard library source
124+
rm -r tests/run-make-cargo/compiler-builtins # Expects lib/rustlib/src/rust to contains the standard library source
125125
rm -r tests/run-make/translation # same
126126
rm -r tests/run-make/missing-unstable-trait-bound # This disables support for unstable features, but running cg_clif needs some unstable features
127127
rm -r tests/run-make/const-trait-stable-toolchain # same
@@ -166,5 +166,5 @@ index 073116933bd..c3e4578204d 100644
166166
EOF
167167

168168
echo "[TEST] rustc test suite"
169-
./x.py test --stage 0 --test-args=--no-capture tests/{codegen-units,run-make,ui,incremental}
169+
./x.py test --stage 0 --test-args=--no-capture tests/{codegen-units,run-make,run-make-cargo,ui,incremental}
170170
popd

compiler/rustc_codegen_gcc/build_system/src/test.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,27 +1083,36 @@ where
10831083

10841084
fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10851085
test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?;
1086+
test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo")?;
10861087
test_rustc_inner(env, args, |_| Ok(false), false, "ui")
10871088
}
10881089

10891090
fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1090-
let result1 = test_rustc_inner(
1091+
let run_make_result = test_rustc_inner(
10911092
env,
10921093
args,
10931094
retain_files_callback("tests/failing-run-make-tests.txt", "run-make"),
10941095
false,
10951096
"run-make",
10961097
);
10971098

1098-
let result2 = test_rustc_inner(
1099+
let run_make_cargo_result = test_rustc_inner(
1100+
env,
1101+
args,
1102+
retain_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"),
1103+
false,
1104+
"run-make",
1105+
);
1106+
1107+
let ui_result = test_rustc_inner(
10991108
env,
11001109
args,
11011110
retain_files_callback("tests/failing-ui-tests.txt", "ui"),
11021111
false,
11031112
"ui",
11041113
);
11051114

1106-
result1.and(result2)
1115+
run_make_result.and(run_make_cargo_result).and(ui_result)
11071116
}
11081117

11091118
fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
@@ -1120,6 +1129,13 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
11201129
remove_files_callback("tests/failing-run-make-tests.txt", "run-make"),
11211130
false,
11221131
"run-make",
1132+
)?;
1133+
test_rustc_inner(
1134+
env,
1135+
args,
1136+
remove_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"),
1137+
false,
1138+
"run-make-cargo",
11231139
)
11241140
}
11251141

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",
@@ -1128,8 +1129,8 @@ impl<'a> Builder<'a> {
11281129
test::RustInstaller,
11291130
test::TestFloatParse,
11301131
test::CollectLicenseMetadata,
1131-
// Run run-make last, since these won't pass without make on Windows
11321132
test::RunMake,
1133+
test::RunMakeCargo,
11331134
),
11341135
Kind::Miri => describe!(test::Crate),
11351136
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
@@ -2152,8 +2152,9 @@ mod snapshot {
21522152
[build] rustc 0 <host> -> HtmlChecker 1 <host>
21532153
[test] html-check <host>
21542154
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2155-
[build] rustc 0 <host> -> cargo 1 <host>
21562155
[test] compiletest-run-make 1 <host>
2156+
[build] rustc 0 <host> -> cargo 1 <host>
2157+
[test] compiletest-run-make-cargo 1 <host>
21572158
");
21582159
}
21592160

@@ -2171,7 +2172,6 @@ mod snapshot {
21712172
[test] compiletest-ui 1 <host>
21722173
[test] compiletest-ui-fulldeps 1 <host>
21732174
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2174-
[build] rustc 0 <host> -> cargo 1 <host>
21752175
[build] rustdoc 1 <host>
21762176
[test] compiletest-run-make 1 <host>
21772177
[test] compiletest-rustdoc 1 <host>
@@ -2200,7 +2200,6 @@ mod snapshot {
22002200
[build] rustc 2 <host> -> rustc 3 <host>
22012201
[test] compiletest-ui-fulldeps 2 <host>
22022202
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2203-
[build] rustc 1 <host> -> cargo 2 <host>
22042203
[build] rustdoc 2 <host>
22052204
[test] compiletest-run-make 2 <host>
22062205
[test] compiletest-rustdoc 2 <host>
@@ -2234,7 +2233,6 @@ mod snapshot {
22342233
[build] rustc 2 <host> -> rustc 3 <target1>
22352234
[test] compiletest-ui-fulldeps 2 <target1>
22362235
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2237-
[build] rustc 1 <host> -> cargo 2 <host>
22382236
[build] rustdoc 2 <host>
22392237
[test] compiletest-run-make 2 <target1>
22402238
[test] compiletest-rustdoc 2 <target1>
@@ -2329,8 +2327,9 @@ mod snapshot {
23292327
[build] rustc 0 <host> -> HtmlChecker 1 <host>
23302328
[test] html-check <host>
23312329
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2332-
[build] rustc 1 <host> -> cargo 2 <host>
23332330
[test] compiletest-run-make 2 <host>
2331+
[build] rustc 1 <host> -> cargo 2 <host>
2332+
[test] compiletest-run-make-cargo 2 <host>
23342333
");
23352334
}
23362335

@@ -2464,6 +2463,43 @@ mod snapshot {
24642463
");
24652464
}
24662465

2466+
// Differential snapshots for `./x test run-make` run `./x test run-make-cargo`: only
2467+
// `run-make-cargo` should build an in-tree cargo, running `./x test run-make` should not.
2468+
#[test]
2469+
fn test_run_make_no_cargo() {
2470+
let ctx = TestCtx::new();
2471+
insta::assert_snapshot!(
2472+
ctx.config("test")
2473+
.path("run-make")
2474+
.render_steps(), @r"
2475+
[build] llvm <host>
2476+
[build] rustc 0 <host> -> rustc 1 <host>
2477+
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2478+
[build] rustc 1 <host> -> std 1 <host>
2479+
[build] rustc 0 <host> -> Compiletest 1 <host>
2480+
[build] rustdoc 1 <host>
2481+
[test] compiletest-run-make 1 <host>
2482+
");
2483+
}
2484+
2485+
#[test]
2486+
fn test_run_make_cargo_builds_cargo() {
2487+
let ctx = TestCtx::new();
2488+
insta::assert_snapshot!(
2489+
ctx.config("test")
2490+
.path("run-make-cargo")
2491+
.render_steps(), @r"
2492+
[build] llvm <host>
2493+
[build] rustc 0 <host> -> rustc 1 <host>
2494+
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
2495+
[build] rustc 1 <host> -> std 1 <host>
2496+
[build] rustc 0 <host> -> Compiletest 1 <host>
2497+
[build] rustc 0 <host> -> cargo 1 <host>
2498+
[build] rustdoc 1 <host>
2499+
[test] compiletest-run-make-cargo 1 <host>
2500+
");
2501+
}
2502+
24672503
#[test]
24682504
fn doc_all() {
24692505
let ctx = TestCtx::new();

src/ci/docker/host-aarch64/aarch64-gnu-debug/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ ENV RUST_CONFIGURE_ARGS \
5454

5555
ENV SCRIPT \
5656
python3 ../x.py --stage 2 build && \
57-
python3 ../x.py --stage 2 test tests/run-make
57+
python3 ../x.py --stage 2 test tests/run-make tests/run-make-cargo

src/ci/docker/host-x86_64/dist-various-1/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ ENV RUST_CONFIGURE_ARGS \
158158
--disable-docs
159159

160160
ENV SCRIPT \
161-
python3 ../x.py --stage 2 test --host='' --target $RUN_MAKE_TARGETS tests/run-make && \
161+
python3 ../x.py --stage 2 test --host='' --target $RUN_MAKE_TARGETS tests/run-make tests/run-make-cargo && \
162162
python3 ../x.py dist --host='' --target $TARGETS
163163

164164
# sccache

src/ci/docker/host-x86_64/test-various/Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v19.0
6060
tar -xJ
6161
ENV PATH "$PATH:/wasmtime-v19.0.0-x86_64-linux"
6262

63-
ENV WASM_WASIP_TARGET=wasm32-wasip1
63+
ENV WASM_WASIP_TARGET=wasm32-wasip1
6464
ENV WASM_WASIP_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_WASIP_TARGET \
6565
tests/run-make \
66+
tests/run-make-cargo \
6667
tests/ui \
6768
tests/mir-opt \
6869
tests/codegen-units \
@@ -73,6 +74,7 @@ ENV WASM_WASIP_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $
7374
ENV NVPTX_TARGETS=nvptx64-nvidia-cuda
7475
ENV NVPTX_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $NVPTX_TARGETS \
7576
tests/run-make \
77+
tests/run-make-cargo \
7678
tests/assembly-llvm
7779

7880
ENV MUSL_TARGETS=x86_64-unknown-linux-musl \
@@ -88,8 +90,8 @@ ENV UEFI_TARGETS=aarch64-unknown-uefi,i686-unknown-uefi,x86_64-unknown-uefi \
8890
CC_x86_64_unknown_uefi=clang-11 \
8991
CXX_x86_64_unknown_uefi=clang++-11
9092
ENV UEFI_SCRIPT python3 /checkout/x.py --stage 2 build --host='' --target $UEFI_TARGETS && \
91-
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target aarch64-unknown-uefi && \
92-
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target i686-unknown-uefi && \
93-
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target x86_64-unknown-uefi
93+
python3 /checkout/x.py --stage 2 test tests/run-make-cargo/uefi-qemu/rmake.rs --target aarch64-unknown-uefi && \
94+
python3 /checkout/x.py --stage 2 test tests/run-make-cargo/uefi-qemu/rmake.rs --target i686-unknown-uefi && \
95+
python3 /checkout/x.py --stage 2 test tests/run-make-cargo/uefi-qemu/rmake.rs --target x86_64-unknown-uefi
9496

9597
ENV SCRIPT $WASM_WASIP_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT

src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ ENV RUST_CONFIGURE_ARGS \
5656
ENV SCRIPT \
5757
python3 ../x.py --stage 2 build && \
5858
python3 ../x.py --stage 2 test tests/ui && \
59-
python3 ../x.py --stage 2 test tests/run-make
59+
python3 ../x.py --stage 2 test tests/run-make tests/run-make-cargo

src/doc/rustc-dev-guide/src/tests/adding.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ guidelines:
2929
suites.
3030
- Need to inspect the resulting binary in some way? Or if all the other test
3131
suites are too limited for your purposes? Then use `run-make`.
32+
- Use `run-make-cargo` if you need to exercise in-tree `cargo` in conjunction
33+
with in-tree `rustc`.
3234
- Check out the [compiletest] chapter for more specialized test suites.
3335

3436
After deciding on which kind of test to add, see [best

0 commit comments

Comments
 (0)