Skip to content

Commit 74c3ea5

Browse files
committed
Auto merge of #1105 - RalfJung:readme, r=oli-obk
better way to ignore tests in Miri This is better because it avoids warnings due to unused imports (the ignored tests still get compiled, just not executed).
2 parents 754c4a4 + b883c11 commit 74c3ea5

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ interpreted program or test suite after the second `--`. For example, `cargo
7979
miri run -- -Zmiri-disable-validation` runs the program without validation of
8080
basic type invariants and without checking the aliasing of references.
8181

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

8686
```rust
87-
#[cfg(not(miri))]
8887
#[test]
88+
#[cfg_attr(miri, ignore)]
8989
fn does_not_work_on_miri() {
9090
std::thread::spawn(|| println!("Hello Thread!"))
9191
.join()

test-cargo-miri/test.stdout.ref

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ test test::rng ... ok
55
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
66

77

8-
running 6 tests
8+
running 7 tests
99
test do_panic ... ok
10+
test does_not_work_on_miri ... ignored
1011
test entropy_rng ... ok
1112
test fail_index_check ... ok
1213
test num_cpus ... ok
1314
test simple1 ... ok
1415
test simple2 ... ok
1516

16-
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
17+
test result: ok. 6 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
1718

test-cargo-miri/test.stdout.ref2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
77
running 1 test
88
test simple1 ... ok
99

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

test-cargo-miri/test.stdout.ref3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
77
running 1 test
88
test num_cpus ... ok
99

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

test-cargo-miri/tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fn simple2() {
1313
}
1414

1515
// A test that won't work on miri (tests disabling tests).
16-
#[cfg(not(miri))]
1716
#[test]
17+
#[cfg_attr(miri, ignore)]
1818
fn does_not_work_on_miri() {
1919
let x = 0u8;
2020
assert!(&x as *const _ as usize % 4 < 4);

0 commit comments

Comments
 (0)