Skip to content

Commit b1080b2

Browse files
committed
Auto merge of rust-lang#123317 - RalfJung:test-in-miri, r=m-ou-se,saethlin,onur-ozkan
Support running library tests in Miri This adds a new bootstrap subcommand `./x.py miri` which can test libraries in Miri. This is in preparation for eventually doing that as part of bors CI, but this PR only adds the infrastructure, and doesn't enable it yet. `@rust-lang/bootstrap` should this be `x.py test --miri library/core` or `x.py miri library/core`? The flag has the advantage that we don't have to copy all the arguments from `Subcommand::Test`. It has the disadvantage that most test steps just ignore `--miri` and still run tests the regular way. For clippy you went the route of making it a separate subcommand. ~~I went with a flag now as that seemed easier, but I can change this.~~ I made it a new subcommand. Note however that the regular cargo invocation would be `cargo miri test ...`, so `x.py` is still going to be different in that the `test` is omitted. That said, we could also make it `./x.py miri-test` to make that difference smaller -- that's in fact more consistent with the internal name of the command when bootstrap invokes cargo. `@rust-lang/libs` ~~unfortunately this PR does some unholy things to the `lib.rs` files of our library crates.~~ `@m-ou-se` found a way that entirely avoids library-level hacks, except for some new small `lib.miri.rs` files that hopefully you will never have to touch. There's a new hack in cargo-miri but there it is in good company...
2 parents 0200bb5 + de6296d commit b1080b2

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

alloc/benches/vec_deque_append.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ const WARMUP_N: usize = 100;
55
const BENCH_N: usize = 1000;
66

77
fn main() {
8+
if cfg!(miri) {
9+
// Don't benchmark Miri...
10+
// (Due to bootstrap quirks, this gets picked up by `x.py miri library/alloc --no-doc`.)
11+
return;
12+
}
813
let a: VecDeque<i32> = (0..VECDEQUE_LEN).collect();
914
let b: VecDeque<i32> = (0..VECDEQUE_LEN).collect();
1015

alloc/src/lib.miri.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//! Grep bootstrap for `MIRI_REPLACE_LIBRS_IF_NOT_TEST` to learn what this is about.
2+
#![no_std]
3+
extern crate alloc as realalloc;
4+
pub use realalloc::*;

core/src/lib.miri.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//! Grep bootstrap for `MIRI_REPLACE_LIBRS_IF_NOT_TEST` to learn what this is about.
2+
#![no_std]
3+
extern crate core as realcore;
4+
pub use realcore::*;

std/src/lib.miri.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//! Grep bootstrap for `MIRI_REPLACE_LIBRS_IF_NOT_TEST` to learn what this is about.
2+
#![no_std]
3+
extern crate std as realstd;
4+
pub use realstd::*;

0 commit comments

Comments
 (0)