Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ rm tests/ui/abi/large-byval-align.rs # exceeds implementation limit of Cranelift
# ============================================================
rm -r tests/run-make/remap-path-prefix-dwarf # requires llvm-dwarfdump
rm -r tests/run-make/strip # same
rm -r tests/run-make/compiler-builtins # Expects lib/rustlib/src/rust to contains the standard library source
rm -r tests/run-make-cargo/compiler-builtins # Expects lib/rustlib/src/rust to contains the standard library source
rm -r tests/run-make/translation # same
rm -r tests/run-make/missing-unstable-trait-bound # This disables support for unstable features, but running cg_clif needs some unstable features
rm -r tests/run-make/const-trait-stable-toolchain # same
Expand Down Expand Up @@ -166,5 +166,5 @@ index 073116933bd..c3e4578204d 100644
EOF

echo "[TEST] rustc test suite"
./x.py test --stage 0 --test-args=--no-capture tests/{codegen-units,run-make,ui,incremental}
./x.py test --stage 0 --test-args=--no-capture tests/{codegen-units,run-make,run-make-cargo,ui,incremental}
popd
22 changes: 19 additions & 3 deletions compiler/rustc_codegen_gcc/build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,27 +1083,36 @@ where

fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?;
test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo")?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @antoyo @GuillaumeGomez: could you check if these changes look right?

test_rustc_inner(env, args, |_| Ok(false), false, "ui")
}

fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
let result1 = test_rustc_inner(
let run_make_result = test_rustc_inner(
env,
args,
retain_files_callback("tests/failing-run-make-tests.txt", "run-make"),
false,
"run-make",
);

let result2 = test_rustc_inner(
let run_make_cargo_result = test_rustc_inner(
env,
args,
retain_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: I thought about splitting out failing-run-make-cargo-tests.txt but that seem like a lot of ceremony, and the ones that were moved into run-make-cargo weren't previously in the list anyway.

false,
"run-make",
);

let ui_result = test_rustc_inner(
env,
args,
retain_files_callback("tests/failing-ui-tests.txt", "ui"),
false,
"ui",
);

result1.and(result2)
run_make_result.and(run_make_cargo_result).and(ui_result)
}

fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
Expand All @@ -1120,6 +1129,13 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
remove_files_callback("tests/failing-run-make-tests.txt", "run-make"),
false,
"run-make",
)?;
test_rustc_inner(
env,
args,
remove_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"),
false,
"run-make-cargo",
)
}

Expand Down
52 changes: 37 additions & 15 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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" {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: I almost missed this until I noticed that the snapshot tests for ./x test run-make-cargo didn't have a step for building run-make-support, and I was like "huh, how strange".

builder.tool_exe(Tool::RunMakeSupport);
}

Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: make comment above was outdated.

),
Kind::Miri => describe!(test::Crate),
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
Expand Down
46 changes: 41 additions & 5 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
");
}

Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
");
}

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-aarch64/aarch64-gnu-debug/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ ENV RUST_CONFIGURE_ARGS \

ENV SCRIPT \
python3 ../x.py --stage 2 build && \
python3 ../x.py --stage 2 test tests/run-make
python3 ../x.py --stage 2 test tests/run-make tests/run-make-cargo
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/dist-various-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ ENV RUST_CONFIGURE_ARGS \
--disable-docs

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

# sccache
Expand Down
10 changes: 6 additions & 4 deletions src/ci/docker/host-x86_64/test-various/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v19.0
tar -xJ
ENV PATH "$PATH:/wasmtime-v19.0.0-x86_64-linux"

ENV WASM_WASIP_TARGET=wasm32-wasip1
ENV WASM_WASIP_TARGET=wasm32-wasip1
ENV WASM_WASIP_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_WASIP_TARGET \
tests/run-make \
tests/run-make-cargo \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: these CI changes should not cause CI time to regress, because we should be doing approximately the same amount of work as before (i.e. still building in-tree cargo).

tests/ui \
tests/mir-opt \
tests/codegen-units \
Expand All @@ -73,6 +74,7 @@ ENV WASM_WASIP_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $
ENV NVPTX_TARGETS=nvptx64-nvidia-cuda
ENV NVPTX_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $NVPTX_TARGETS \
tests/run-make \
tests/run-make-cargo \
tests/assembly-llvm

ENV MUSL_TARGETS=x86_64-unknown-linux-musl \
Expand All @@ -88,8 +90,8 @@ ENV UEFI_TARGETS=aarch64-unknown-uefi,i686-unknown-uefi,x86_64-unknown-uefi \
CC_x86_64_unknown_uefi=clang-11 \
CXX_x86_64_unknown_uefi=clang++-11
ENV UEFI_SCRIPT python3 /checkout/x.py --stage 2 build --host='' --target $UEFI_TARGETS && \
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target aarch64-unknown-uefi && \
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target i686-unknown-uefi && \
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target x86_64-unknown-uefi
python3 /checkout/x.py --stage 2 test tests/run-make-cargo/uefi-qemu/rmake.rs --target aarch64-unknown-uefi && \
python3 /checkout/x.py --stage 2 test tests/run-make-cargo/uefi-qemu/rmake.rs --target i686-unknown-uefi && \
python3 /checkout/x.py --stage 2 test tests/run-make-cargo/uefi-qemu/rmake.rs --target x86_64-unknown-uefi

ENV SCRIPT $WASM_WASIP_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ ENV RUST_CONFIGURE_ARGS \
ENV SCRIPT \
python3 ../x.py --stage 2 build && \
python3 ../x.py --stage 2 test tests/ui && \
python3 ../x.py --stage 2 test tests/run-make
python3 ../x.py --stage 2 test tests/run-make tests/run-make-cargo
2 changes: 2 additions & 0 deletions src/doc/rustc-dev-guide/src/tests/adding.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ guidelines:
suites.
- Need to inspect the resulting binary in some way? Or if all the other test
suites are too limited for your purposes? Then use `run-make`.
- Use `run-make-cargo` if you need to exercise in-tree `cargo` in conjunction
with in-tree `rustc`.
- Check out the [compiletest] chapter for more specialized test suites.

After deciding on which kind of test to add, see [best
Expand Down
8 changes: 4 additions & 4 deletions src/doc/rustc-dev-guide/src/tests/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ related tests.
- E.g. for an implementation of RFC 2093 specifically, we can group a
collection of tests under `tests/ui/rfc-2093-infer-outlives/`. For the
directory name, include what the RFC is about.
- For the [`run-make`] test suite, each `rmake.rs` must be contained within an
immediate subdirectory under `tests/run-make/`. Further nesting is not
presently supported. Avoid including issue number in the directory name too,
include that info in a comment inside `rmake.rs`.
- For the [`run-make`]/`run-make-support` test suites, each `rmake.rs` must
be contained within an immediate subdirectory under `tests/run-make/` or
`tests/run-make-cargo/` respectively. Further nesting is not presently
supported. Avoid using _only_ an issue number for the test name as well.

## Test descriptions

Expand Down
15 changes: 11 additions & 4 deletions src/doc/rustc-dev-guide/src/tests/compiletest.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,19 @@ your test, causing separate files to be generated for 32bit and 64bit systems.

### `run-make` tests

The tests in [`tests/run-make`] are general-purpose tests using Rust *recipes*,
which are small programs (`rmake.rs`) allowing arbitrary Rust code such as
`rustc` invocations, and is supported by a [`run_make_support`] library. Using
Rust recipes provide the ultimate in flexibility.
The tests in [`tests/run-make`] and [`tests/run-make-cargo`] are general-purpose
tests using Rust *recipes*, which are small programs (`rmake.rs`) allowing
arbitrary Rust code such as `rustc` invocations, and is supported by a
[`run_make_support`] library. Using Rust recipes provide the ultimate in
flexibility.

`run-make` tests should be used if no other test suites better suit your needs.

The `run-make-cargo` test suite additionally builds an in-tree `cargo` to support
use cases that require testing in-tree `cargo` in conjunction with in-tree `rustc`.
The `run-make` test suite does not have access to in-tree `cargo` (so it can be the
faster-to-iterate test suite).

#### Using Rust recipes

Each test should be in a separate directory with a `rmake.rs` Rust program,
Expand Down Expand Up @@ -476,6 +482,7 @@ Then add a corresponding entry to `"rust-analyzer.linkedProjects"`
```

[`tests/run-make`]: https://github.com/rust-lang/rust/tree/master/tests/run-make
[`tests/run-make-cargo`]: https://github.com/rust-lang/rust/tree/master/tests/run-make-cargo
[`run_make_support`]: https://github.com/rust-lang/rust/tree/master/src/tools/run-make-support

### Coverage tests
Expand Down
Loading
Loading