Skip to content

Commit 9708644

Browse files
authored
Rollup merge of #58275 - RalfJung:miri-test-libcore, r=Mark-Simulacrum
libcore, liballoc: disable tests in Miri I am going to run the libcore and liballoc unit test suites in Miri. Not all tests pass. This PR disables a whole bunch of tests when running in Miri, to get us to a baseline from which I can investigate failures. Cc @SimonSapin @alexcrichton
2 parents c3b4102 + 81613ad commit 9708644

File tree

20 files changed

+81
-0
lines changed

20 files changed

+81
-0
lines changed

src/liballoc/tests/arc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(miri))]
2+
13
use std::any::Any;
24
use std::sync::{Arc, Weak};
35
use std::cell::RefCell;

src/liballoc/tests/binary_heap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ fn assert_covariance() {
282282
//
283283
// Destructors must be called exactly once per element.
284284
#[test]
285+
#[cfg(not(miri))]
285286
fn panic_safe() {
286287
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
287288

src/liballoc/tests/btree/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(miri))]
2+
13
mod map;
24
mod set;
35

src/liballoc/tests/heap.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(miri))]
2+
13
use std::alloc::{Global, Alloc, Layout, System};
24

35
/// https://github.com/rust-lang/rust/issues/45955

src/liballoc/tests/rc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(miri))]
2+
13
use std::any::Any;
24
use std::rc::{Rc, Weak};
35
use std::cell::RefCell;

src/liballoc/tests/slice.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(miri))]
2+
13
use std::cell::Cell;
24
use std::cmp::Ordering::{self, Equal, Greater, Less};
35
use std::mem;

src/liballoc/tests/str.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fn test_rfind() {
3131
}
3232

3333
#[test]
34+
#[cfg(not(miri))]
3435
fn test_collect() {
3536
let empty = "";
3637
let s: String = empty.chars().collect();
@@ -118,6 +119,7 @@ fn test_concat_for_different_types() {
118119
#[test]
119120
fn test_concat_for_different_lengths() {
120121
let empty: &[&str] = &[];
122+
#[cfg(not(miri))]
121123
test_concat!("", empty);
122124
test_concat!("a", ["a"]);
123125
test_concat!("ab", ["a", "b"]);
@@ -146,6 +148,7 @@ fn test_join_for_different_types() {
146148
#[test]
147149
fn test_join_for_different_lengths() {
148150
let empty: &[&str] = &[];
151+
#[cfg(not(miri))]
149152
test_join!("", empty, "-");
150153
test_join!("a", ["a"], "-");
151154
test_join!("a-b", ["a", "b"], "-");
@@ -159,13 +162,15 @@ fn test_join_for_different_lengths_with_long_separator() {
159162
assert_eq!("~~~~~".len(), 15);
160163

161164
let empty: &[&str] = &[];
165+
#[cfg(not(miri))]
162166
test_join!("", empty, "~~~~~");
163167
test_join!("a", ["a"], "~~~~~");
164168
test_join!("a~~~~~b", ["a", "b"], "~~~~~");
165169
test_join!("~~~~~a~~~~~bc", ["", "a", "bc"], "~~~~~");
166170
}
167171

168172
#[test]
173+
#[cfg(not(miri))]
169174
fn test_unsafe_slice() {
170175
assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
171176
assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
@@ -238,6 +243,7 @@ fn test_replacen() {
238243
#[test]
239244
fn test_replace() {
240245
let a = "a";
246+
#[cfg(not(miri))]
241247
assert_eq!("".replace(a, "b"), "");
242248
assert_eq!("a".replace(a, "b"), "b");
243249
assert_eq!("ab".replace(a, "b"), "bb");
@@ -297,6 +303,7 @@ fn test_replace_pattern() {
297303
// The current implementation of SliceIndex fails to handle methods
298304
// orthogonally from range types; therefore, it is worth testing
299305
// all of the indexing operations on each input.
306+
#[cfg(not(miri))]
300307
mod slice_index {
301308
// Test a slicing operation **that should succeed,**
302309
// testing it on all of the indexing methods.
@@ -679,6 +686,7 @@ fn test_str_slice_rangetoinclusive_ok() {
679686

680687
#[test]
681688
#[should_panic]
689+
#[cfg(not(miri))]
682690
fn test_str_slice_rangetoinclusive_notok() {
683691
let s = "abcαβγ";
684692
&s[..=3];
@@ -694,6 +702,7 @@ fn test_str_slicemut_rangetoinclusive_ok() {
694702

695703
#[test]
696704
#[should_panic]
705+
#[cfg(not(miri))]
697706
fn test_str_slicemut_rangetoinclusive_notok() {
698707
let mut s = "abcαβγ".to_owned();
699708
let s: &mut str = &mut s;
@@ -883,6 +892,7 @@ fn test_as_bytes() {
883892

884893
#[test]
885894
#[should_panic]
895+
#[cfg(not(miri))]
886896
fn test_as_bytes_fail() {
887897
// Don't double free. (I'm not sure if this exercises the
888898
// original problem code path anymore.)
@@ -972,6 +982,7 @@ fn test_split_at_mut() {
972982

973983
#[test]
974984
#[should_panic]
985+
#[cfg(not(miri))]
975986
fn test_split_at_boundscheck() {
976987
let s = "ศไทย中华Việt Nam";
977988
s.split_at(1);
@@ -1066,6 +1077,7 @@ fn test_rev_iterator() {
10661077
}
10671078

10681079
#[test]
1080+
#[cfg(not(miri))]
10691081
fn test_chars_decoding() {
10701082
let mut bytes = [0; 4];
10711083
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1077,6 +1089,7 @@ fn test_chars_decoding() {
10771089
}
10781090

10791091
#[test]
1092+
#[cfg(not(miri))]
10801093
fn test_chars_rev_decoding() {
10811094
let mut bytes = [0; 4];
10821095
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1306,6 +1319,7 @@ fn test_splitator() {
13061319
}
13071320

13081321
#[test]
1322+
#[cfg(not(miri))]
13091323
fn test_str_default() {
13101324
use std::default::Default;
13111325

@@ -1365,6 +1379,7 @@ fn test_bool_from_str() {
13651379
assert_eq!("not even a boolean".parse::<bool>().ok(), None);
13661380
}
13671381

1382+
#[cfg(not(miri))]
13681383
fn check_contains_all_substrings(s: &str) {
13691384
assert!(s.contains(""));
13701385
for i in 0..s.len() {
@@ -1375,6 +1390,7 @@ fn check_contains_all_substrings(s: &str) {
13751390
}
13761391

13771392
#[test]
1393+
#[cfg(not(miri))]
13781394
fn strslice_issue_16589() {
13791395
assert!("bananas".contains("nana"));
13801396

@@ -1384,13 +1400,15 @@ fn strslice_issue_16589() {
13841400
}
13851401

13861402
#[test]
1403+
#[cfg(not(miri))]
13871404
fn strslice_issue_16878() {
13881405
assert!(!"1234567ah012345678901ah".contains("hah"));
13891406
assert!(!"00abc01234567890123456789abc".contains("bcabc"));
13901407
}
13911408

13921409

13931410
#[test]
1411+
#[cfg(not(miri))]
13941412
fn test_strslice_contains() {
13951413
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
13961414
check_contains_all_substrings(x);
@@ -1528,6 +1546,7 @@ fn trim_ws() {
15281546

15291547
#[test]
15301548
fn to_lowercase() {
1549+
#[cfg(not(miri))]
15311550
assert_eq!("".to_lowercase(), "");
15321551
assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé ");
15331552

@@ -1561,6 +1580,7 @@ fn to_lowercase() {
15611580

15621581
#[test]
15631582
fn to_uppercase() {
1583+
#[cfg(not(miri))]
15641584
assert_eq!("".to_uppercase(), "");
15651585
assert_eq!("aéDžßfiᾀ".to_uppercase(), "AÉDŽSSFIἈΙ");
15661586
}
@@ -1592,6 +1612,7 @@ fn test_cow_from() {
15921612
}
15931613

15941614
#[test]
1615+
#[cfg(not(miri))]
15951616
fn test_repeat() {
15961617
assert_eq!("".repeat(3), "");
15971618
assert_eq!("abc".repeat(0), "");

src/liballoc/tests/string.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(miri))]
2+
13
use std::borrow::Cow;
24
use std::collections::CollectionAllocErr::*;
35
use std::mem::size_of;

src/liballoc/tests/vec.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(miri))]
2+
13
use std::borrow::Cow;
24
use std::mem::size_of;
35
use std::{usize, isize};

src/liballoc/tests/vec_deque.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ fn test_index() {
108108

109109
#[test]
110110
#[should_panic]
111+
#[cfg(not(miri))]
111112
fn test_index_out_of_bounds() {
112113
let mut deq = VecDeque::new();
113114
for i in 1..4 {
@@ -906,20 +907,24 @@ fn test_append() {
906907
// normal append
907908
a.append(&mut b);
908909
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
910+
#[cfg(not(miri))]
909911
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
910912

911913
// append nothing to something
912914
a.append(&mut b);
913915
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
916+
#[cfg(not(miri))]
914917
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
915918

916919
// append something to nothing
917920
b.append(&mut a);
918921
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
922+
#[cfg(not(miri))]
919923
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), []);
920924
}
921925

922926
#[test]
927+
#[cfg(not(miri))]
923928
fn test_append_permutations() {
924929
fn construct_vec_deque(
925930
push_back: usize,
@@ -1120,6 +1125,7 @@ fn test_reserve_exact_2() {
11201125
}
11211126

11221127
#[test]
1128+
#[cfg(not(miri))]
11231129
fn test_try_reserve() {
11241130

11251131
// These are the interesting cases:
@@ -1221,6 +1227,7 @@ fn test_try_reserve() {
12211227
}
12221228

12231229
#[test]
1230+
#[cfg(not(miri))]
12241231
fn test_try_reserve_exact() {
12251232

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

0 commit comments

Comments
 (0)