Skip to content

Commit f42a6d1

Browse files
author
hyd-dev
committed
Skip doctests of proc-macro crates
1 parent 62046bf commit f42a6d1

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

cargo-miri/bin.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,13 @@ fn phase_rustdoc(fst_arg: &str, mut args: env::Args) {
903903
show_error(format!("cross-interpreting doc-tests is not currently supported by Miri."));
904904
}
905905

906+
// Doc-tests of `proc-macro` crates (and their dependencies) are always built for the host,
907+
// so we are not able to run them in Miri.
908+
if ArgFlagValueIter::new("--crate-type").any(|crate_type| crate_type == "proc-macro") {
909+
eprintln!("Running doc-tests of `proc-macro` crates is not currently supported by Miri.");
910+
return;
911+
}
912+
906913
// For each doc-test, rustdoc starts two child processes: first the test is compiled,
907914
// then the produced executable is invoked. We want to reroute both of these to cargo-miri,
908915
// such that the first time we'll enter phase_cargo_rustc, and phase_cargo_runner second.

test-cargo-miri/run-test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ def test_cargo_miri_test():
140140
"test.subcrate.stdout.ref", "test.stderr-proc-macro.ref",
141141
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
142142
)
143+
test("`cargo miri test` (subcrate, doctests)",
144+
cargo_miri("test") + ["-p", "subcrate", "--doc"],
145+
"test.stdout-empty.ref", "test.stderr-proc-macro-doctest.ref",
146+
)
143147

144148
os.chdir(os.path.dirname(os.path.realpath(__file__)))
145149
os.environ["RUST_TEST_NOCAPTURE"] = "0" # this affects test output, so make sure it is not set

test-cargo-miri/subcrate/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
#[cfg(doctest)]
2+
use num_cpus as _;
3+
14
#[cfg(test)]
25
compile_error!("Miri should not touch me");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Running doc-tests of `proc-macro` crates is not currently supported by Miri.

test-cargo-miri/test.stdout-empty.ref

Whitespace-only changes.

0 commit comments

Comments
 (0)