Skip to content

Commit ca2ffe3

Browse files
committed
liballoc: ignore tests in Miri instead of removing them entirely
1 parent 7ba1232 commit ca2ffe3

File tree

9 files changed

+23
-24
lines changed

9 files changed

+23
-24
lines changed

src/liballoc/alloc/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn allocate_zeroed() {
2222
}
2323

2424
#[bench]
25-
#[cfg(not(miri))] // Miri does not support benchmarks
25+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
2626
fn alloc_owned_small(b: &mut Bencher) {
2727
b.iter(|| {
2828
let _: Box<_> = box 10;

src/liballoc/collections/linked_list/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn test_insert_prev() {
182182

183183
#[test]
184184
#[cfg_attr(target_os = "emscripten", ignore)]
185-
#[cfg(not(miri))] // Miri does not support threads
185+
#[cfg_attr(miri, ignore)] // Miri does not support threads
186186
fn test_send() {
187187
let n = list_from(&[1, 2, 3]);
188188
thread::spawn(move || {

src/liballoc/collections/vec_deque/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use ::test;
44

55
#[bench]
6-
#[cfg(not(miri))] // Miri does not support benchmarks
6+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
77
fn bench_push_back_100(b: &mut test::Bencher) {
88
let mut deq = VecDeque::with_capacity(101);
99
b.iter(|| {
@@ -16,7 +16,7 @@ fn bench_push_back_100(b: &mut test::Bencher) {
1616
}
1717

1818
#[bench]
19-
#[cfg(not(miri))] // Miri does not support benchmarks
19+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
2020
fn bench_push_front_100(b: &mut test::Bencher) {
2121
let mut deq = VecDeque::with_capacity(101);
2222
b.iter(|| {
@@ -29,7 +29,7 @@ fn bench_push_front_100(b: &mut test::Bencher) {
2929
}
3030

3131
#[bench]
32-
#[cfg(not(miri))] // Miri does not support benchmarks
32+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
3333
fn bench_pop_back_100(b: &mut test::Bencher) {
3434
let mut deq = VecDeque::<i32>::with_capacity(101);
3535

@@ -43,7 +43,7 @@ fn bench_pop_back_100(b: &mut test::Bencher) {
4343
}
4444

4545
#[bench]
46-
#[cfg(not(miri))] // Miri does not support benchmarks
46+
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
4747
fn bench_pop_front_100(b: &mut test::Bencher) {
4848
let mut deq = VecDeque::<i32>::with_capacity(101);
4949

src/liballoc/sync/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Drop for Canary {
2929

3030
#[test]
3131
#[cfg_attr(target_os = "emscripten", ignore)]
32-
#[cfg(not(miri))] // Miri does not support threads
32+
#[cfg_attr(miri, ignore)] // Miri does not support threads
3333
fn manually_share_arc() {
3434
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
3535
let arc_v = Arc::new(v);
@@ -334,7 +334,7 @@ fn test_ptr_eq() {
334334

335335
#[test]
336336
#[cfg_attr(target_os = "emscripten", ignore)]
337-
#[cfg(not(miri))] // Miri does not support threads
337+
#[cfg_attr(miri, ignore)] // Miri does not support threads
338338
fn test_weak_count_locked() {
339339
let mut a = Arc::new(atomic::AtomicBool::new(false));
340340
let a2 = a.clone();

src/liballoc/tests/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ fn test_reverse() {
388388
}
389389

390390
#[test]
391-
#[cfg(not(miri))] // Miri is too slow
391+
#[cfg_attr(miri, ignore)] // Miri is too slow
392392
fn test_sort() {
393393
let mut rng = thread_rng();
394394

@@ -1610,7 +1610,7 @@ fn panic_safe() {
16101610
let moduli = &[5, 20, 50];
16111611

16121612
#[cfg(miri)]
1613-
let lens = (1..13);
1613+
let lens = 1..13;
16141614
#[cfg(miri)]
16151615
let moduli = &[10];
16161616

src/liballoc/tests/str.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fn test_join_for_different_lengths_with_long_separator() {
166166
}
167167

168168
#[test]
169-
#[cfg(not(miri))] // Miri is too slow
169+
#[cfg_attr(miri, ignore)] // Miri is too slow
170170
fn test_unsafe_slice() {
171171
assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
172172
assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
@@ -483,8 +483,8 @@ mod slice_index {
483483
}
484484

485485
#[test]
486-
#[cfg(not(target_os = "emscripten"))] // hits an OOM
487-
#[cfg(not(miri))] // Miri is too slow
486+
#[cfg_attr(target_os = "emscripten", ignore)] // hits an OOM
487+
#[cfg_attr(miri, ignore)] // Miri is too slow
488488
fn simple_big() {
489489
fn a_million_letter_x() -> String {
490490
let mut i = 0;
@@ -1069,7 +1069,7 @@ fn test_rev_iterator() {
10691069
}
10701070

10711071
#[test]
1072-
#[cfg(not(miri))] // Miri is too slow
1072+
#[cfg_attr(miri, ignore)] // Miri is too slow
10731073
fn test_chars_decoding() {
10741074
let mut bytes = [0; 4];
10751075
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1081,7 +1081,7 @@ fn test_chars_decoding() {
10811081
}
10821082

10831083
#[test]
1084-
#[cfg(not(miri))] // Miri is too slow
1084+
#[cfg_attr(miri, ignore)] // Miri is too slow
10851085
fn test_chars_rev_decoding() {
10861086
let mut bytes = [0; 4];
10871087
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1380,7 +1380,6 @@ fn test_bool_from_str() {
13801380
assert_eq!("not even a boolean".parse::<bool>().ok(), None);
13811381
}
13821382

1383-
#[cfg(not(miri))] // Miri is too slow
13841383
fn check_contains_all_substrings(s: &str) {
13851384
assert!(s.contains(""));
13861385
for i in 0..s.len() {
@@ -1391,7 +1390,7 @@ fn check_contains_all_substrings(s: &str) {
13911390
}
13921391

13931392
#[test]
1394-
#[cfg(not(miri))] // Miri is too slow
1393+
#[cfg_attr(miri, ignore)] // Miri is too slow
13951394
fn strslice_issue_16589() {
13961395
assert!("bananas".contains("nana"));
13971396

@@ -1408,7 +1407,7 @@ fn strslice_issue_16878() {
14081407

14091408

14101409
#[test]
1411-
#[cfg(not(miri))] // Miri is too slow
1410+
#[cfg_attr(miri, ignore)] // Miri is too slow
14121411
fn test_strslice_contains() {
14131412
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
14141413
check_contains_all_substrings(x);

src/liballoc/tests/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ fn test_reserve_exact() {
523523
}
524524

525525
#[test]
526-
#[cfg(not(miri))] // Miri does not support signalling OOM
526+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
527527
fn test_try_reserve() {
528528

529529
// These are the interesting cases:
@@ -601,7 +601,7 @@ fn test_try_reserve() {
601601
}
602602

603603
#[test]
604-
#[cfg(not(miri))] // Miri does not support signalling OOM
604+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
605605
fn test_try_reserve_exact() {
606606

607607
// This is exactly the same as test_try_reserve with the method changed.

src/liballoc/tests/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ fn test_reserve_exact() {
10801080
}
10811081

10821082
#[test]
1083-
#[cfg(not(miri))] // Miri does not support signalling OOM
1083+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
10841084
fn test_try_reserve() {
10851085

10861086
// These are the interesting cases:
@@ -1183,7 +1183,7 @@ fn test_try_reserve() {
11831183
}
11841184

11851185
#[test]
1186-
#[cfg(not(miri))] // Miri does not support signalling OOM
1186+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
11871187
fn test_try_reserve_exact() {
11881188

11891189
// This is exactly the same as test_try_reserve with the method changed.

src/liballoc/tests/vec_deque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ fn test_reserve_exact_2() {
11001100
}
11011101

11021102
#[test]
1103-
#[cfg(not(miri))] // Miri does not support signalling OOM
1103+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
11041104
fn test_try_reserve() {
11051105
// These are the interesting cases:
11061106
// * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
@@ -1214,7 +1214,7 @@ fn test_try_reserve() {
12141214
}
12151215

12161216
#[test]
1217-
#[cfg(not(miri))] // Miri does not support signalling OOM
1217+
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
12181218
fn test_try_reserve_exact() {
12191219
// This is exactly the same as test_try_reserve with the method changed.
12201220
// See that test for comments.

0 commit comments

Comments
 (0)