1
Fork 0

enable cargo miri test doctests

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan 2024-03-25 23:34:01 +03:00
parent 42198bf562
commit 69af113f44
3 changed files with 14 additions and 4 deletions

View file

@ -680,9 +680,13 @@ impl Step for Miri {
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join("src/tools/miri/test-cargo-miri/Cargo.toml")); .arg(builder.src.join("src/tools/miri/test-cargo-miri/Cargo.toml"));
cargo.arg("--target").arg(target.rustc_target_arg()); cargo.arg("--target").arg(target.rustc_target_arg());
cargo.arg("--tests"); // don't run doctests, they are too confused by the staging
cargo.arg("--").args(builder.config.test_args()); cargo.arg("--").args(builder.config.test_args());
// `prepare_tool_cargo` sets RUSTDOC to the bootstrap wrapper and RUSTDOC_REAL to a dummy path as this is a "run", not a "test".
// Also, we want the rustdoc from the "next" stage for the same reason that we build a std from the next stage.
// So let's just set that here, and bypass bootstrap's RUSTDOC (just like cargo-miri already ignores bootstrap's RUSTC_WRAPPER).
cargo.env("RUSTDOC", builder.rustdoc(compiler_std));
// Tell `cargo miri` where to find things. // Tell `cargo miri` where to find things.
cargo.env("MIRI_SYSROOT", &miri_sysroot); cargo.env("MIRI_SYSROOT", &miri_sysroot);
cargo.env("MIRI_HOST_SYSROOT", sysroot); cargo.env("MIRI_HOST_SYSROOT", sysroot);

View file

@ -505,6 +505,8 @@ binaries, and as such worth documenting:
* `MIRI_LOCAL_CRATES` is set by `cargo-miri` to tell the Miri driver which * `MIRI_LOCAL_CRATES` is set by `cargo-miri` to tell the Miri driver which
crates should be given special treatment in diagnostics, in addition to the crates should be given special treatment in diagnostics, in addition to the
crate currently being compiled. crate currently being compiled.
* `MIRI_ORIG_RUSTDOC` is set and read by different phases of `cargo-miri` to remember the
value of `RUSTDOC` from before it was overwritten.
* `MIRI_VERBOSE` when set to any value tells the various `cargo-miri` phases to * `MIRI_VERBOSE` when set to any value tells the various `cargo-miri` phases to
perform verbose logging. perform verbose logging.
* `MIRI_HOST_SYSROOT` is set by bootstrap to tell `cargo-miri` which sysroot to use for *host* * `MIRI_HOST_SYSROOT` is set by bootstrap to tell `cargo-miri` which sysroot to use for *host*

View file

@ -202,6 +202,9 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
cmd.env("MIRI_BE_RUSTC", "target"); // we better remember to *unset* this in the other phases! cmd.env("MIRI_BE_RUSTC", "target"); // we better remember to *unset* this in the other phases!
// Set rustdoc to us as well, so we can run doctests. // Set rustdoc to us as well, so we can run doctests.
if let Some(orig_rustdoc) = env::var_os("RUSTDOC") {
cmd.env("MIRI_ORIG_RUSTDOC", orig_rustdoc);
}
cmd.env("RUSTDOC", &cargo_miri_path); cmd.env("RUSTDOC", &cargo_miri_path);
cmd.env("MIRI_LOCAL_CRATES", local_crates(&metadata)); cmd.env("MIRI_LOCAL_CRATES", local_crates(&metadata));
@ -581,9 +584,10 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
let verbose = std::env::var("MIRI_VERBOSE") let verbose = std::env::var("MIRI_VERBOSE")
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer")); .map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
// phase_cargo_miri sets the RUSTDOC env var to ourselves, so we can't use that here; // phase_cargo_miri sets the RUSTDOC env var to ourselves, and puts a backup
// just default to a straight-forward invocation for now: // of the old value into MIRI_ORIG_RUSTDOC. So that's what we have to invoke now.
let mut cmd = Command::new("rustdoc"); let rustdoc = env::var("MIRI_ORIG_RUSTDOC").unwrap_or("rustdoc".to_string());
let mut cmd = Command::new(rustdoc);
let extern_flag = "--extern"; let extern_flag = "--extern";
let runtool_flag = "--runtool"; let runtool_flag = "--runtool";