Skip to content

Commit

Permalink
enable more panic-catching tests in Miri
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 23, 2019
1 parent 8af2f22 commit a229979
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/liballoc/tests/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,10 @@ fn panic_safe() {
}
let mut rng = thread_rng();
const DATASZ: usize = 32;
#[cfg(not(miri))] // Miri is too slow
const NTEST: usize = 10;
#[cfg(miri)]
const NTEST: usize = 1;

// don't use 0 in the data -- we want to catch the zeroed-out case.
let data = (1..=DATASZ).collect::<Vec<_>>();
Expand Down
16 changes: 12 additions & 4 deletions src/liballoc/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1605,12 +1605,17 @@ fn panic_safe() {
let mut rng = thread_rng();

#[cfg(not(miri))] // Miri is too slow
let large_range = 70..MAX_LEN;
let lens = (1..20).chain(70..MAX_LEN);
#[cfg(not(miri))] // Miri is too slow
let moduli = &[5, 20, 50];

#[cfg(miri)]
let large_range = 0..0; // empty range
let lens = (1..13);
#[cfg(miri)]
let moduli = &[10];

for len in (1..20).chain(large_range) {
for &modulus in &[5, 20, 50] {
for len in lens {
for &modulus in moduli {
for &has_runs in &[false, true] {
let mut input = (0..len)
.map(|id| {
Expand Down Expand Up @@ -1643,6 +1648,9 @@ fn panic_safe() {
}
}
}

// Set default panic hook again.
drop(panic::take_hook());
}

#[test]
Expand Down

0 comments on commit a229979

Please sign in to comment.