Skip to content

Commit 4c1a1c3

Browse files
committed
review failures in btree, string
1 parent b17ca01 commit 4c1a1c3

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

src/liballoc/tests/btree/map.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::iter::FromIterator;
77
use super::DeterministicRng;
88

99
#[test]
10+
#[cfg(not(miri))] // Miri is too slow
1011
fn test_basic_large() {
1112
let mut map = BTreeMap::new();
1213
let size = 10000;
@@ -69,7 +70,10 @@ fn test_basic_small() {
6970

7071
#[test]
7172
fn test_iter() {
73+
#[cfg(not(miri))] // Miri is too slow
7274
let size = 10000;
75+
#[cfg(miri)]
76+
let size = 100;
7377

7478
// Forwards
7579
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -91,7 +95,10 @@ fn test_iter() {
9195

9296
#[test]
9397
fn test_iter_rev() {
98+
#[cfg(not(miri))] // Miri is too slow
9499
let size = 10000;
100+
#[cfg(miri)]
101+
let size = 100;
95102

96103
// Forwards
97104
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -127,7 +134,10 @@ fn test_values_mut() {
127134

128135
#[test]
129136
fn test_iter_mixed() {
137+
#[cfg(not(miri))] // Miri is too slow
130138
let size = 10000;
139+
#[cfg(miri)]
140+
let size = 100;
131141

132142
// Forwards
133143
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -214,42 +224,50 @@ fn test_range_equal_empty_cases() {
214224

215225
#[test]
216226
#[should_panic]
227+
#[cfg(not(miri))] // Miri does not support panics
217228
fn test_range_equal_excluded() {
218229
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
219230
map.range((Excluded(2), Excluded(2)));
220231
}
221232

222233
#[test]
223234
#[should_panic]
235+
#[cfg(not(miri))] // Miri does not support panics
224236
fn test_range_backwards_1() {
225237
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
226238
map.range((Included(3), Included(2)));
227239
}
228240

229241
#[test]
230242
#[should_panic]
243+
#[cfg(not(miri))] // Miri does not support panics
231244
fn test_range_backwards_2() {
232245
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
233246
map.range((Included(3), Excluded(2)));
234247
}
235248

236249
#[test]
237250
#[should_panic]
251+
#[cfg(not(miri))] // Miri does not support panics
238252
fn test_range_backwards_3() {
239253
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
240254
map.range((Excluded(3), Included(2)));
241255
}
242256

243257
#[test]
244258
#[should_panic]
259+
#[cfg(not(miri))] // Miri does not support panics
245260
fn test_range_backwards_4() {
246261
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
247262
map.range((Excluded(3), Excluded(2)));
248263
}
249264

250265
#[test]
251266
fn test_range_1000() {
267+
#[cfg(not(miri))] // Miri is too slow
252268
let size = 1000;
269+
#[cfg(miri)]
270+
let size = 100;
253271
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
254272

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

287305
#[test]
288306
fn test_range() {
307+
#[cfg(not(miri))] // Miri is too slow
289308
let size = 200;
309+
#[cfg(miri)]
310+
let size = 20;
290311
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
291312

292313
for i in 0..size {
@@ -305,7 +326,10 @@ fn test_range() {
305326

306327
#[test]
307328
fn test_range_mut() {
329+
#[cfg(not(miri))] // Miri is too slow
308330
let size = 200;
331+
#[cfg(miri)]
332+
let size = 20;
309333
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
310334

311335
for i in 0..size {
@@ -479,7 +503,10 @@ fn test_bad_zst() {
479503
#[test]
480504
fn test_clone() {
481505
let mut map = BTreeMap::new();
506+
#[cfg(not(miri))] // Miri is too slow
482507
let size = 100;
508+
#[cfg(miri)]
509+
let size = 20;
483510
assert_eq!(map.len(), 0);
484511

485512
for i in 0..size {
@@ -631,6 +658,7 @@ create_append_test!(test_append_145, 145);
631658
create_append_test!(test_append_170, 170);
632659
create_append_test!(test_append_181, 181);
633660
create_append_test!(test_append_239, 239);
661+
#[cfg(not(miri))] // Miri is too slow
634662
create_append_test!(test_append_1700, 1700);
635663

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

src/liballoc/tests/btree/mod.rs

Lines changed: 0 additions & 2 deletions
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/string.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::borrow::Cow;
42
use std::collections::CollectionAllocErr::*;
53
use std::mem::size_of;
@@ -233,6 +231,7 @@ fn test_split_off_empty() {
233231

234232
#[test]
235233
#[should_panic]
234+
#[cfg(not(miri))] // Miri does not support panics
236235
fn test_split_off_past_end() {
237236
let orig = "Hello, world!";
238237
let mut split = String::from(orig);
@@ -241,6 +240,7 @@ fn test_split_off_past_end() {
241240

242241
#[test]
243242
#[should_panic]
243+
#[cfg(not(miri))] // Miri does not support panics
244244
fn test_split_off_mid_char() {
245245
let mut orig = String::from("山");
246246
orig.split_off(1);
@@ -289,6 +289,7 @@ fn test_str_truncate_invalid_len() {
289289

290290
#[test]
291291
#[should_panic]
292+
#[cfg(not(miri))] // Miri does not support panics
292293
fn test_str_truncate_split_codepoint() {
293294
let mut s = String::from("\u{FC}"); // ü
294295
s.truncate(1);
@@ -323,6 +324,7 @@ fn remove() {
323324

324325
#[test]
325326
#[should_panic]
327+
#[cfg(not(miri))] // Miri does not support panics
326328
fn remove_bad() {
327329
"ศ".to_string().remove(1);
328330
}
@@ -358,11 +360,13 @@ fn insert() {
358360

359361
#[test]
360362
#[should_panic]
363+
#[cfg(not(miri))] // Miri does not support panics
361364
fn insert_bad1() {
362365
"".to_string().insert(1, 't');
363366
}
364367
#[test]
365368
#[should_panic]
369+
#[cfg(not(miri))] // Miri does not support panics
366370
fn insert_bad2() {
367371
"ệ".to_string().insert(1, 't');
368372
}
@@ -443,6 +447,7 @@ fn test_replace_range() {
443447

444448
#[test]
445449
#[should_panic]
450+
#[cfg(not(miri))] // Miri does not support panics
446451
fn test_replace_range_char_boundary() {
447452
let mut s = "Hello, 世界!".to_owned();
448453
s.replace_range(..8, "");
@@ -459,13 +464,15 @@ fn test_replace_range_inclusive_range() {
459464

460465
#[test]
461466
#[should_panic]
467+
#[cfg(not(miri))] // Miri does not support panics
462468
fn test_replace_range_out_of_bounds() {
463469
let mut s = String::from("12345");
464470
s.replace_range(5..6, "789");
465471
}
466472

467473
#[test]
468474
#[should_panic]
475+
#[cfg(not(miri))] // Miri does not support panics
469476
fn test_replace_range_inclusive_out_of_bounds() {
470477
let mut s = String::from("12345");
471478
s.replace_range(5..=5, "789");
@@ -525,6 +532,7 @@ fn test_reserve_exact() {
525532
}
526533

527534
#[test]
535+
#[cfg(not(miri))] // Miri does not support signalling OOM
528536
fn test_try_reserve() {
529537

530538
// These are the interesting cases:
@@ -602,6 +610,7 @@ fn test_try_reserve() {
602610
}
603611

604612
#[test]
613+
#[cfg(not(miri))] // Miri does not support signalling OOM
605614
fn test_try_reserve_exact() {
606615

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

src/liballoc/tests/vec_deque.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,6 @@ fn test_append() {
921921
}
922922

923923
#[test]
924-
#[cfg(not(miri))] // Miri is too slow
925924
fn test_append_permutations() {
926925
fn construct_vec_deque(
927926
push_back: usize,
@@ -945,7 +944,10 @@ fn test_append_permutations() {
945944
out
946945
}
947946

947+
#[cfg(not(miri))] // Miri is too slow
948948
const MAX: usize = 5;
949+
#[cfg(miri)]
950+
const MAX: usize = 3;
949951

950952
// Many different permutations of both the `VecDeque` getting appended to
951953
// and the one getting appended are generated to check `append`.

src/libcore/tests/fmt/builders.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ mod debug_list {
488488
}
489489

490490
#[test]
491-
#[cfg(not(miri))] // FIXME uses code in liballoc, investigate Stacked Borrows failure
492491
fn test_formatting_parameters_are_forwarded() {
493492
use std::collections::{BTreeMap, BTreeSet};
494493
#[derive(Debug)]

0 commit comments

Comments
 (0)