Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

we can now skip should_panic tests with the libtest harness #59072

Merged
merged 2 commits into from
Mar 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/liballoc/tests/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn assert_covariance() {
//
// Destructors must be called exactly once per element.
#[test]
#[cfg(not(miri))] // Miri does not support panics
#[cfg(not(miri))] // Miri does not support panics nor entropy
fn panic_safe() {
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);

Expand Down
5 changes: 0 additions & 5 deletions src/liballoc/tests/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,39 +226,34 @@ fn test_range_equal_empty_cases() {

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

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

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

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

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_4() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Excluded(3), Excluded(2)));
Expand Down
20 changes: 2 additions & 18 deletions src/liballoc/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ fn test_swap_remove() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_swap_remove_fail() {
let mut v = vec![1];
let _ = v.swap_remove(0);
Expand Down Expand Up @@ -632,7 +631,6 @@ fn test_insert() {

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

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_remove_fail() {
let mut a = vec![1];
let _ = a.remove(0);
Expand Down Expand Up @@ -939,7 +936,6 @@ fn test_windowsator() {

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

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

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

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

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

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

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

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

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

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

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_mut_rchunks_exact_0() {
let mut v = [1, 2, 3, 4];
let _it = v.rchunks_exact_mut(0);
Expand Down Expand Up @@ -1411,7 +1397,7 @@ fn test_box_slice_clone() {
#[test]
#[allow(unused_must_use)] // here, we care about the side effects of `.clone()`
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg(not(miri))] // Miri does not support panics
#[cfg(not(miri))] // Miri does not support threads nor entropy
fn test_box_slice_clone_panics() {
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
Expand Down Expand Up @@ -1476,7 +1462,6 @@ fn test_copy_from_slice() {

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

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

#[test]
#[cfg_attr(target_os = "emscripten", ignore)] // no threads
#[cfg(not(miri))] // Miri does not support panics
#[cfg(not(miri))] // Miri does not support threads nor entropy
fn panic_safe() {
let prev = panic::take_hook();
panic::set_hook(Box::new(move |info| {
Expand Down
11 changes: 0 additions & 11 deletions src/liballoc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ mod slice_index {
// to be used in `should_panic`)
#[test]
#[should_panic(expected = "out of bounds")]
#[cfg(not(miri))] // Miri does not support panics
fn assert_range_eq_can_fail_by_panic() {
assert_range_eq!("abc", 0..5, "abc");
}
Expand All @@ -361,7 +360,6 @@ mod slice_index {
// to be used in `should_panic`)
#[test]
#[should_panic(expected = "==")]
#[cfg(not(miri))] // Miri does not support panics
fn assert_range_eq_can_fail_by_inequality() {
assert_range_eq!("abc", 0..2, "abc");
}
Expand Down Expand Up @@ -409,7 +407,6 @@ mod slice_index {

#[test]
#[should_panic(expected = $expect_msg)]
#[cfg(not(miri))] // Miri does not support panics
fn index_fail() {
let v: String = $data.into();
let v: &str = &v;
Expand All @@ -418,7 +415,6 @@ mod slice_index {

#[test]
#[should_panic(expected = $expect_msg)]
#[cfg(not(miri))] // Miri does not support panics
fn index_mut_fail() {
let mut v: String = $data.into();
let v: &mut str = &mut v;
Expand Down Expand Up @@ -514,7 +510,6 @@ mod slice_index {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_fail() {
&"中华Việt Nam"[0..2];
}
Expand Down Expand Up @@ -666,14 +661,12 @@ mod slice_index {
// check the panic includes the prefix of the sliced string
#[test]
#[should_panic(expected="byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_fail_truncated_1() {
&LOREM_PARAGRAPH[..1024];
}
// check the truncation in the panic message
#[test]
#[should_panic(expected="luctus, im`[...]")]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_fail_truncated_2() {
&LOREM_PARAGRAPH[..1024];
}
Expand All @@ -688,7 +681,6 @@ fn test_str_slice_rangetoinclusive_ok() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_str_slice_rangetoinclusive_notok() {
let s = "abcαβγ";
&s[..=3];
Expand All @@ -704,7 +696,6 @@ fn test_str_slicemut_rangetoinclusive_ok() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_str_slicemut_rangetoinclusive_notok() {
let mut s = "abcαβγ".to_owned();
let s: &mut str = &mut s;
Expand Down Expand Up @@ -894,7 +885,6 @@ fn test_as_bytes() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_as_bytes_fail() {
// Don't double free. (I'm not sure if this exercises the
// original problem code path anymore.)
Expand Down Expand Up @@ -984,7 +974,6 @@ fn test_split_at_mut() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_split_at_boundscheck() {
let s = "ศไทย中华Việt Nam";
s.split_at(1);
Expand Down
9 changes: 0 additions & 9 deletions src/liballoc/tests/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ fn test_split_off_empty() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_split_off_past_end() {
let orig = "Hello, world!";
let mut split = String::from(orig);
Expand All @@ -240,7 +239,6 @@ fn test_split_off_past_end() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_split_off_mid_char() {
let mut orig = String::from("山");
orig.split_off(1);
Expand Down Expand Up @@ -289,7 +287,6 @@ fn test_str_truncate_invalid_len() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_str_truncate_split_codepoint() {
let mut s = String::from("\u{FC}"); // ü
s.truncate(1);
Expand Down Expand Up @@ -324,7 +321,6 @@ fn remove() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn remove_bad() {
"ศ".to_string().remove(1);
}
Expand Down Expand Up @@ -360,13 +356,11 @@ fn insert() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn insert_bad1() {
"".to_string().insert(1, 't');
}
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn insert_bad2() {
"ệ".to_string().insert(1, 't');
}
Expand Down Expand Up @@ -447,7 +441,6 @@ fn test_replace_range() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_replace_range_char_boundary() {
let mut s = "Hello, 世界!".to_owned();
s.replace_range(..8, "");
Expand All @@ -464,15 +457,13 @@ fn test_replace_range_inclusive_range() {

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_replace_range_out_of_bounds() {
let mut s = String::from("12345");
s.replace_range(5..6, "789");
}

#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_replace_range_inclusive_out_of_bounds() {
let mut s = String::from("12345");
s.replace_range(5..=5, "789");
Expand Down
Loading