Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better way to ignore tests in Miri #1105

Merged
merged 2 commits into from
Dec 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ interpreted program or test suite after the second `--`. For example, `cargo
miri run -- -Zmiri-disable-validation` runs the program without validation of
basic type invariants and without checking the aliasing of references.

When running code via `cargo miri`, the `miri` config flag is set. You can
use this to exclude test cases that will fail under Miri because they do things
When compiling code via `cargo miri`, the `miri` config flag is set. You can
use this to ignore test cases that will fail under Miri because they do things
Miri does not support:

```rust
#[cfg(not(miri))]
#[test]
#[cfg_attr(miri, ignore)]
fn does_not_work_on_miri() {
std::thread::spawn(|| println!("Hello Thread!"))
.join()
Expand Down
5 changes: 3 additions & 2 deletions test-cargo-miri/test.stdout.ref
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ test test::rng ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out


running 6 tests
running 7 tests
test do_panic ... ok
test does_not_work_on_miri ... ignored
test entropy_rng ... ok
test fail_index_check ... ok
test num_cpus ... ok
test simple1 ... ok
test simple2 ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
test result: ok. 6 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out

2 changes: 1 addition & 1 deletion test-cargo-miri/test.stdout.ref2
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
running 1 test
test simple1 ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out

2 changes: 1 addition & 1 deletion test-cargo-miri/test.stdout.ref3
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
running 1 test
test num_cpus ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out

2 changes: 1 addition & 1 deletion test-cargo-miri/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fn simple2() {
}

// A test that won't work on miri (tests disabling tests).
#[cfg(not(miri))]
#[test]
#[cfg_attr(miri, ignore)]
fn does_not_work_on_miri() {
let x = 0u8;
assert!(&x as *const _ as usize % 4 < 4);
Expand Down