Skip to content

Commit 0fecb6d

Browse files
committed
Rollup merge of rust-lang#58433 - RalfJung:miri-mark-tests, r=TimNN
Update which libcore/liballoc tests Miri ignores, and document why
2 parents 13b055d + c154bf7 commit 0fecb6d

24 files changed

+150
-79
lines changed

src/liballoc/tests/arc.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::any::Any;
42
use std::sync::{Arc, Weak};
53
use std::cell::RefCell;

src/liballoc/tests/binary_heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ fn assert_covariance() {
282282
//
283283
// Destructors must be called exactly once per element.
284284
#[test]
285-
#[cfg(not(miri))]
285+
#[cfg(not(miri))] // Miri does not support panics
286286
fn panic_safe() {
287287
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
288288

src/liballoc/tests/btree/map.rs

+30
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use super::DeterministicRng;
99
#[test]
1010
fn test_basic_large() {
1111
let mut map = BTreeMap::new();
12+
#[cfg(not(miri))] // Miri is too slow
1213
let size = 10000;
14+
#[cfg(miri)]
15+
let size = 200;
1316
assert_eq!(map.len(), 0);
1417

1518
for i in 0..size {
@@ -69,7 +72,10 @@ fn test_basic_small() {
6972

7073
#[test]
7174
fn test_iter() {
75+
#[cfg(not(miri))] // Miri is too slow
7276
let size = 10000;
77+
#[cfg(miri)]
78+
let size = 200;
7379

7480
// Forwards
7581
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -91,7 +97,10 @@ fn test_iter() {
9197

9298
#[test]
9399
fn test_iter_rev() {
100+
#[cfg(not(miri))] // Miri is too slow
94101
let size = 10000;
102+
#[cfg(miri)]
103+
let size = 200;
95104

96105
// Forwards
97106
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -127,7 +136,10 @@ fn test_values_mut() {
127136

128137
#[test]
129138
fn test_iter_mixed() {
139+
#[cfg(not(miri))] // Miri is too slow
130140
let size = 10000;
141+
#[cfg(miri)]
142+
let size = 200;
131143

132144
// Forwards
133145
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -214,42 +226,50 @@ fn test_range_equal_empty_cases() {
214226

215227
#[test]
216228
#[should_panic]
229+
#[cfg(not(miri))] // Miri does not support panics
217230
fn test_range_equal_excluded() {
218231
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
219232
map.range((Excluded(2), Excluded(2)));
220233
}
221234

222235
#[test]
223236
#[should_panic]
237+
#[cfg(not(miri))] // Miri does not support panics
224238
fn test_range_backwards_1() {
225239
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
226240
map.range((Included(3), Included(2)));
227241
}
228242

229243
#[test]
230244
#[should_panic]
245+
#[cfg(not(miri))] // Miri does not support panics
231246
fn test_range_backwards_2() {
232247
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
233248
map.range((Included(3), Excluded(2)));
234249
}
235250

236251
#[test]
237252
#[should_panic]
253+
#[cfg(not(miri))] // Miri does not support panics
238254
fn test_range_backwards_3() {
239255
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
240256
map.range((Excluded(3), Included(2)));
241257
}
242258

243259
#[test]
244260
#[should_panic]
261+
#[cfg(not(miri))] // Miri does not support panics
245262
fn test_range_backwards_4() {
246263
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
247264
map.range((Excluded(3), Excluded(2)));
248265
}
249266

250267
#[test]
251268
fn test_range_1000() {
269+
#[cfg(not(miri))] // Miri is too slow
252270
let size = 1000;
271+
#[cfg(miri)]
272+
let size = 200;
253273
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
254274

255275
fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
@@ -286,7 +306,10 @@ fn test_range_borrowed_key() {
286306

287307
#[test]
288308
fn test_range() {
309+
#[cfg(not(miri))] // Miri is too slow
289310
let size = 200;
311+
#[cfg(miri)]
312+
let size = 30;
290313
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
291314

292315
for i in 0..size {
@@ -305,7 +328,10 @@ fn test_range() {
305328

306329
#[test]
307330
fn test_range_mut() {
331+
#[cfg(not(miri))] // Miri is too slow
308332
let size = 200;
333+
#[cfg(miri)]
334+
let size = 30;
309335
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
310336

311337
for i in 0..size {
@@ -479,7 +505,10 @@ fn test_bad_zst() {
479505
#[test]
480506
fn test_clone() {
481507
let mut map = BTreeMap::new();
508+
#[cfg(not(miri))] // Miri is too slow
482509
let size = 100;
510+
#[cfg(miri)]
511+
let size = 30;
483512
assert_eq!(map.len(), 0);
484513

485514
for i in 0..size {
@@ -631,6 +660,7 @@ create_append_test!(test_append_145, 145);
631660
create_append_test!(test_append_170, 170);
632661
create_append_test!(test_append_181, 181);
633662
create_append_test!(test_append_239, 239);
663+
#[cfg(not(miri))] // Miri is too slow
634664
create_append_test!(test_append_1700, 1700);
635665

636666
fn rand_data(len: usize) -> Vec<(u32, u32)> {

src/liballoc/tests/btree/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
mod map;
42
mod set;
53

src/liballoc/tests/heap.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::alloc::{Global, Alloc, Layout, System};
42

53
/// Issue #45955.

src/liballoc/tests/rc.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::any::Any;
42
use std::rc::{Rc, Weak};
53
use std::cell::RefCell;

src/liballoc/tests/slice.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::cell::Cell;
42
use std::cmp::Ordering::{self, Equal, Greater, Less};
53
use std::mem;
@@ -260,6 +258,7 @@ fn test_swap_remove() {
260258

261259
#[test]
262260
#[should_panic]
261+
#[cfg(not(miri))] // Miri does not support panics
263262
fn test_swap_remove_fail() {
264263
let mut v = vec![1];
265264
let _ = v.swap_remove(0);
@@ -391,6 +390,7 @@ fn test_reverse() {
391390
}
392391

393392
#[test]
393+
#[cfg(not(miri))] // Miri does not support entropy
394394
fn test_sort() {
395395
let mut rng = thread_rng();
396396

@@ -467,6 +467,7 @@ fn test_sort() {
467467
}
468468

469469
#[test]
470+
#[cfg(not(miri))] // Miri does not support entropy
470471
fn test_sort_stability() {
471472
for len in (2..25).chain(500..510) {
472473
for _ in 0..10 {
@@ -631,6 +632,7 @@ fn test_insert() {
631632

632633
#[test]
633634
#[should_panic]
635+
#[cfg(not(miri))] // Miri does not support panics
634636
fn test_insert_oob() {
635637
let mut a = vec![1, 2, 3];
636638
a.insert(4, 5);
@@ -655,6 +657,7 @@ fn test_remove() {
655657

656658
#[test]
657659
#[should_panic]
660+
#[cfg(not(miri))] // Miri does not support panics
658661
fn test_remove_fail() {
659662
let mut a = vec![1];
660663
let _ = a.remove(0);
@@ -936,6 +939,7 @@ fn test_windowsator() {
936939

937940
#[test]
938941
#[should_panic]
942+
#[cfg(not(miri))] // Miri does not support panics
939943
fn test_windowsator_0() {
940944
let v = &[1, 2, 3, 4];
941945
let _it = v.windows(0);
@@ -960,6 +964,7 @@ fn test_chunksator() {
960964

961965
#[test]
962966
#[should_panic]
967+
#[cfg(not(miri))] // Miri does not support panics
963968
fn test_chunksator_0() {
964969
let v = &[1, 2, 3, 4];
965970
let _it = v.chunks(0);
@@ -984,6 +989,7 @@ fn test_chunks_exactator() {
984989

985990
#[test]
986991
#[should_panic]
992+
#[cfg(not(miri))] // Miri does not support panics
987993
fn test_chunks_exactator_0() {
988994
let v = &[1, 2, 3, 4];
989995
let _it = v.chunks_exact(0);
@@ -1008,6 +1014,7 @@ fn test_rchunksator() {
10081014

10091015
#[test]
10101016
#[should_panic]
1017+
#[cfg(not(miri))] // Miri does not support panics
10111018
fn test_rchunksator_0() {
10121019
let v = &[1, 2, 3, 4];
10131020
let _it = v.rchunks(0);
@@ -1032,6 +1039,7 @@ fn test_rchunks_exactator() {
10321039

10331040
#[test]
10341041
#[should_panic]
1042+
#[cfg(not(miri))] // Miri does not support panics
10351043
fn test_rchunks_exactator_0() {
10361044
let v = &[1, 2, 3, 4];
10371045
let _it = v.rchunks_exact(0);
@@ -1084,6 +1092,7 @@ fn test_vec_default() {
10841092

10851093
#[test]
10861094
#[should_panic]
1095+
#[cfg(not(miri))] // Miri does not support panics
10871096
fn test_overflow_does_not_cause_segfault() {
10881097
let mut v = vec![];
10891098
v.reserve_exact(!0);
@@ -1093,6 +1102,7 @@ fn test_overflow_does_not_cause_segfault() {
10931102

10941103
#[test]
10951104
#[should_panic]
1105+
#[cfg(not(miri))] // Miri does not support panics
10961106
fn test_overflow_does_not_cause_segfault_managed() {
10971107
let mut v = vec![Rc::new(1)];
10981108
v.reserve_exact(!0);
@@ -1268,6 +1278,7 @@ fn test_mut_chunks_rev() {
12681278

12691279
#[test]
12701280
#[should_panic]
1281+
#[cfg(not(miri))] // Miri does not support panics
12711282
fn test_mut_chunks_0() {
12721283
let mut v = [1, 2, 3, 4];
12731284
let _it = v.chunks_mut(0);
@@ -1300,6 +1311,7 @@ fn test_mut_chunks_exact_rev() {
13001311

13011312
#[test]
13021313
#[should_panic]
1314+
#[cfg(not(miri))] // Miri does not support panics
13031315
fn test_mut_chunks_exact_0() {
13041316
let mut v = [1, 2, 3, 4];
13051317
let _it = v.chunks_exact_mut(0);
@@ -1332,6 +1344,7 @@ fn test_mut_rchunks_rev() {
13321344

13331345
#[test]
13341346
#[should_panic]
1347+
#[cfg(not(miri))] // Miri does not support panics
13351348
fn test_mut_rchunks_0() {
13361349
let mut v = [1, 2, 3, 4];
13371350
let _it = v.rchunks_mut(0);
@@ -1364,6 +1377,7 @@ fn test_mut_rchunks_exact_rev() {
13641377

13651378
#[test]
13661379
#[should_panic]
1380+
#[cfg(not(miri))] // Miri does not support panics
13671381
fn test_mut_rchunks_exact_0() {
13681382
let mut v = [1, 2, 3, 4];
13691383
let _it = v.rchunks_exact_mut(0);
@@ -1397,6 +1411,7 @@ fn test_box_slice_clone() {
13971411
#[test]
13981412
#[allow(unused_must_use)] // here, we care about the side effects of `.clone()`
13991413
#[cfg_attr(target_os = "emscripten", ignore)]
1414+
#[cfg(not(miri))] // Miri does not support panics
14001415
fn test_box_slice_clone_panics() {
14011416
use std::sync::Arc;
14021417
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -1461,6 +1476,7 @@ fn test_copy_from_slice() {
14611476

14621477
#[test]
14631478
#[should_panic(expected = "destination and source slices have different lengths")]
1479+
#[cfg(not(miri))] // Miri does not support panics
14641480
fn test_copy_from_slice_dst_longer() {
14651481
let src = [0, 1, 2, 3];
14661482
let mut dst = [0; 5];
@@ -1469,6 +1485,7 @@ fn test_copy_from_slice_dst_longer() {
14691485

14701486
#[test]
14711487
#[should_panic(expected = "destination and source slices have different lengths")]
1488+
#[cfg(not(miri))] // Miri does not support panics
14721489
fn test_copy_from_slice_dst_shorter() {
14731490
let src = [0, 1, 2, 3];
14741491
let mut dst = [0; 3];
@@ -1588,6 +1605,7 @@ thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
15881605

15891606
#[test]
15901607
#[cfg_attr(target_os = "emscripten", ignore)] // no threads
1608+
#[cfg(not(miri))] // Miri does not support panics
15911609
fn panic_safe() {
15921610
let prev = panic::take_hook();
15931611
panic::set_hook(Box::new(move |info| {

0 commit comments

Comments
 (0)