Rollup merge of #74974 - RalfJung:miri-tests, r=Mark-Simulacrum

Make tests faster in Miri

Reduce some test iteration counts in Miri.
This commit is contained in:
Yuki Okushi 2020-08-03 01:05:20 +09:00 committed by GitHub
commit 7d18040b0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 12 deletions

View File

@ -107,7 +107,8 @@ fn test_insert() {
let cap = tester.capacity();
// len is the length *after* insertion
for len in 1..cap {
let minlen = if cfg!(miri) { cap - 1 } else { 1 }; // Miri is too slow
for len in minlen..cap {
// 0, 1, 2, .., len - 1
let expected = (0..).take(len).collect::<VecDeque<_>>();
for tail_pos in 0..cap {
@ -221,7 +222,8 @@ fn test_remove() {
let cap = tester.capacity();
// len is the length *after* removal
for len in 0..cap - 1 {
let minlen = if cfg!(miri) { cap - 2 } else { 0 }; // Miri is too slow
for len in minlen..cap - 1 {
// 0, 1, 2, .., len - 1
let expected = (0..).take(len).collect::<VecDeque<_>>();
for tail_pos in 0..cap {
@ -251,7 +253,8 @@ fn test_range() {
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);
let cap = tester.capacity();
for len in 0..=cap {
let minlen = if cfg!(miri) { cap - 1 } else { 0 }; // Miri is too slow
for len in minlen..=cap {
for tail in 0..=cap {
for start in 0..=len {
for end in start..=len {
@ -384,7 +387,8 @@ fn test_split_off() {
let cap = tester.capacity();
// len is the length *before* splitting
for len in 0..cap {
let minlen = if cfg!(miri) { cap - 1 } else { 0 }; // Miri is too slow
for len in minlen..cap {
// index to split at
for at in 0..=len {
// 0, 1, 2, .., at - 1 (may be empty)
@ -495,8 +499,9 @@ fn create_vec_and_test_convert(capacity: usize, offset: usize, len: usize) {
fn test_clone_from() {
let m = vec![1; 8];
let n = vec![2; 12];
for pfv in 0..8 {
for pfu in 0..8 {
let limit = if cfg!(miri) { 4 } else { 8 }; // Miri is too slow
for pfv in 0..limit {
for pfu in 0..limit {
for longer in 0..2 {
let (vr, ur) = if longer == 0 { (&m, &n) } else { (&n, &m) };
let mut v = VecDeque::from(vr.clone());

View File

@ -1721,8 +1721,8 @@ fn panic_safe() {
let mut rng = thread_rng();
// Miri is too slow
let lens = if cfg!(miri) { (1..10).chain(20..21) } else { (1..20).chain(70..MAX_LEN) };
// Miri is too slow (but still need to `chain` to make the types match)
let lens = if cfg!(miri) { (1..10).chain(0..0) } else { (1..20).chain(70..MAX_LEN) };
let moduli: &[u32] = if cfg!(miri) { &[5] } else { &[5, 20, 50] };
for len in lens {

View File

@ -188,7 +188,7 @@ fn exact_f32_random_equivalence_test() {
fn exact_f64_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
// Miri is too slow
let n = if cfg!(miri) { 3 } else { 1_000 };
let n = if cfg!(miri) { 2 } else { 1_000 };
for k in 1..21 {
f64_random_equivalence_test(

View File

@ -2,6 +2,7 @@
use core::num::flt2dec::strategy::grisu::*;
#[test]
#[cfg_attr(miri, ignore)] // Miri is too slow
fn test_cached_power() {
assert_eq!(CACHED_POW10.first().unwrap().1, CACHED_POW10_FIRST_E);
assert_eq!(CACHED_POW10.last().unwrap().1, CACHED_POW10_LAST_E);

View File

@ -1358,15 +1358,15 @@ fn sort_unstable() {
use core::slice::heapsort;
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};
// Miri is too slow
let large_range = if cfg!(miri) { 0..0 } else { 500..510 };
// Miri is too slow (but still need to `chain` to make the types match)
let lens = if cfg!(miri) { (2..20).chain(0..0) } else { (2..25).chain(500..510) };
let rounds = if cfg!(miri) { 1 } else { 100 };
let mut v = [0; 600];
let mut tmp = [0; 600];
let mut rng = StdRng::from_entropy();
for len in (2..25).chain(large_range) {
for len in lens {
let v = &mut v[0..len];
let tmp = &mut tmp[0..len];