Use in-tree Cargo when testing stage 2+ cargo miri

This commit is contained in:
Jakub Beránek
2026-02-19 09:28:17 +01:00
parent d3e8bd94cc
commit 9eb6caa049
2 changed files with 53 additions and 0 deletions
@@ -805,6 +805,20 @@ fn run(self, builder: &Builder<'_>) {
&[],
);
// If we are testing stage 2+ cargo miri, make sure that it works with the in-tree cargo.
// We want to do this *somewhere* to ensure that Miri + nightly cargo actually works.
if stage >= 2 {
let built_cargo = builder
.ensure(tool::Cargo::from_build_compiler(
// Build stage 1 cargo here, we don't need it to be built in any special way,
// just that it is built from in-tree sources.
builder.compiler(0, builder.host_target),
builder.host_target,
))
.tool_path;
cargo.env("CARGO", built_cargo);
}
// We're not using `prepare_cargo_test` so we have to do this ourselves.
// (We're not using that as the test-cargo-miri crate is not known to bootstrap.)
match builder.doc_tests {
+39
View File
@@ -3079,6 +3079,45 @@ fn install_extended() {
");
}
#[test]
fn cargo_miri_stage_1() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("test")
.args(&["cargo-miri"])
.stage(1)
.get_steps()
.render(), @"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 0 <host> -> miri 1 <host>
[build] rustc 0 <host> -> cargo-miri 1 <host>
[build] rustdoc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
");
}
#[test]
fn cargo_miri_stage_2() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("test")
.args(&["cargo-miri"])
.stage(2)
.get_steps()
.render(), @"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> miri 2 <host>
[build] rustc 1 <host> -> cargo-miri 2 <host>
[build] rustdoc 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> cargo 1 <host>
");
}
// Check that `x run miri --target FOO` actually builds miri for the host.
#[test]
fn run_miri() {