Skip to content

Commit d6a9dd6

Browse files
authored
Merge pull request #218 from erickt/miri
Add miri builder
2 parents 10ee11e + 4dd6619 commit d6a9dd6

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

.github/workflows/ci.yml

+15
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,18 @@ jobs:
9393
components: clippy
9494
- run: cargo clippy
9595

96+
miri:
97+
runs-on: ubuntu-latest
98+
strategy:
99+
matrix:
100+
rust:
101+
- nightly
102+
steps:
103+
- uses: actions/checkout@v2
104+
- uses: actions-rs/toolchain@v1
105+
with:
106+
profile: minimal
107+
toolchain: ${{ matrix.rust }}
108+
override: true
109+
components: miri
110+
- run: cargo miri test

src/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ mod tests {
15671567

15681568
let mut keys = vec![];
15691569
keys.extend(0..16);
1570-
keys.extend(128..267);
1570+
keys.extend(if cfg!(miri) { 32..64 } else { 128..267 });
15711571

15721572
for &i in &keys {
15731573
let old_map = map.clone();

src/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ mod tests {
14261426

14271427
let mut values = vec![];
14281428
values.extend(0..16);
1429-
values.extend(128..267);
1429+
values.extend(if cfg!(miri) { 32..64 } else { 128..267 });
14301430

14311431
for &i in &values {
14321432
let old_set = set.clone();

tests/quick.rs

+38-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use indexmap::{IndexMap, IndexSet};
22
use itertools::Itertools;
33

4-
use quickcheck::quickcheck;
54
use quickcheck::Arbitrary;
65
use quickcheck::Gen;
6+
use quickcheck::QuickCheck;
77
use quickcheck::TestResult;
88

99
use fnv::FnvHasher;
@@ -39,7 +39,42 @@ where
3939
IndexMap::from_iter(iter.into_iter().copied().map(|k| (k, ())))
4040
}
4141

42-
quickcheck! {
42+
// Helper macro to allow us to use smaller quickcheck limits under miri.
43+
macro_rules! quickcheck_limit {
44+
(@as_items $($i:item)*) => ($($i)*);
45+
{
46+
$(
47+
$(#[$m:meta])*
48+
fn $fn_name:ident($($arg_name:ident : $arg_ty:ty),*) -> $ret:ty {
49+
$($code:tt)*
50+
}
51+
)*
52+
} => (
53+
quickcheck::quickcheck! {
54+
@as_items
55+
$(
56+
#[test]
57+
$(#[$m])*
58+
fn $fn_name() {
59+
fn prop($($arg_name: $arg_ty),*) -> $ret {
60+
$($code)*
61+
}
62+
let mut quickcheck = QuickCheck::new();
63+
if cfg!(miri) {
64+
quickcheck = quickcheck
65+
.gen(Gen::new(10))
66+
.tests(10)
67+
.max_tests(100);
68+
}
69+
70+
quickcheck.quickcheck(prop as fn($($arg_ty),*) -> $ret);
71+
}
72+
)*
73+
}
74+
)
75+
}
76+
77+
quickcheck_limit! {
4378
fn contains(insert: Vec<u32>) -> bool {
4479
let mut map = IndexMap::new();
4580
for &key in &insert {
@@ -260,7 +295,7 @@ where
260295
true
261296
}
262297

263-
quickcheck! {
298+
quickcheck_limit! {
264299
fn operations_i8(ops: Large<Vec<Op<i8, i8>>>) -> bool {
265300
let mut map = IndexMap::new();
266301
let mut reference = HashMap::new();

0 commit comments

Comments
 (0)