Rollup merge of #123504 - RalfJung:test-cargo-miri, r=Mark-Simulacrum

bootstrap: split cargo-miri test into separate Step

This makes it easier to test just the driver or the cargo-miri integration.

````@rust-lang/miri```` this means to test both you now need to do `./x.py test miri cargo-miri`.
This commit is contained in:
Matthias Krüger 2024-04-06 13:00:06 +02:00 committed by GitHub
commit d9727d1c5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 8 deletions

View File

@ -597,7 +597,7 @@ impl Step for Miri {
builder.ensure(compile::Std::new(target_compiler, host));
let host_sysroot = builder.sysroot(target_compiler);
// # Run `cargo test`.
// Run `cargo test`.
// This is with the Miri crate, so it uses the host compiler.
let mut cargo = tool::prepare_tool_cargo(
builder,
@ -652,15 +652,46 @@ impl Step for Miri {
builder.run(&mut cargo);
}
}
}
}
// # Run `cargo miri test`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CargoMiri {
target: TargetSelection,
}
impl Step for CargoMiri {
type Output = ();
const ONLY_HOSTS: bool = false;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/miri/cargo-miri")
}
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(CargoMiri { target: run.target });
}
/// Tests `cargo miri test`.
fn run(self, builder: &Builder<'_>) {
let host = builder.build.build;
let target = self.target;
let stage = builder.top_stage;
if stage == 0 {
eprintln!("cargo-miri cannot be tested at stage 0");
std::process::exit(1);
}
// This compiler runs on the host, we'll just use it for the target.
let compiler = builder.compiler(stage, host);
// Run `cargo miri test`.
// This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
// that we get the desired output), but that is sufficient to make sure that the libtest harness
// itself executes properly under Miri, and that all the logic in `cargo-miri` does not explode.
// This is running the build `cargo-miri` for the given target, so we need the target compiler.
let mut cargo = tool::prepare_tool_cargo(
builder,
target_compiler,
compiler,
Mode::ToolStd, // it's unclear what to use here, we're not building anything just doing a smoke test!
target,
"miri-test",

View File

@ -808,6 +808,7 @@ impl<'a> Builder<'a> {
test::EditionGuide,
test::Rustfmt,
test::Miri,
test::CargoMiri,
test::Clippy,
test::RustDemangler,
test::CompiletestTest,

View File

@ -32,9 +32,9 @@ python3 "$X_PY" test --stage 2 src/tools/rustfmt
# that bugs which only surface when the GC runs at a specific time are more likely to cause CI to fail.
# This significantly increases the runtime of our test suite, or we'd do this in PR CI too.
if [ -z "${PR_CI_JOB:-}" ]; then
MIRIFLAGS=-Zmiri-provenance-gc=1 python3 "$X_PY" test --stage 2 src/tools/miri
MIRIFLAGS=-Zmiri-provenance-gc=1 python3 "$X_PY" test --stage 2 src/tools/miri src/tools/miri/cargo-miri
else
python3 "$X_PY" test --stage 2 src/tools/miri
python3 "$X_PY" test --stage 2 src/tools/miri src/tools/miri/cargo-miri
fi
# We natively run this script on x86_64-unknown-linux-gnu and x86_64-pc-windows-msvc.
# Also cover some other targets via cross-testing, in particular all tier 1 targets.
@ -42,8 +42,8 @@ case $HOST_TARGET in
x86_64-unknown-linux-gnu)
# Only this branch runs in PR CI.
# Fully test all main OSes, including a 32bit target.
python3 "$X_PY" test --stage 2 src/tools/miri --target x86_64-apple-darwin
python3 "$X_PY" test --stage 2 src/tools/miri --target i686-pc-windows-msvc
python3 "$X_PY" test --stage 2 src/tools/miri src/tools/miri/cargo-miri --target x86_64-apple-darwin
python3 "$X_PY" test --stage 2 src/tools/miri src/tools/miri/cargo-miri --target i686-pc-windows-msvc
# Only run "pass" tests for the remaining targets, which is quite a bit faster.
python3 "$X_PY" test --stage 2 src/tools/miri --target x86_64-pc-windows-gnu --test-args pass
python3 "$X_PY" test --stage 2 src/tools/miri --target i686-unknown-linux-gnu --test-args pass