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

Add miri builder #218

Merged
merged 1 commit into from
Feb 9, 2022
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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,18 @@ jobs:
components: clippy
- run: cargo clippy

miri:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: miri
- run: cargo miri test
2 changes: 1 addition & 1 deletion src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ mod tests {

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

for &i in &keys {
let old_map = map.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ mod tests {

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

for &i in &values {
let old_set = set.clone();
Expand Down
41 changes: 38 additions & 3 deletions tests/quick.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use indexmap::{IndexMap, IndexSet};
use itertools::Itertools;

use quickcheck::quickcheck;
use quickcheck::Arbitrary;
use quickcheck::Gen;
use quickcheck::QuickCheck;
use quickcheck::TestResult;

use fnv::FnvHasher;
Expand Down Expand Up @@ -39,7 +39,42 @@ where
IndexMap::from_iter(iter.into_iter().copied().map(|k| (k, ())))
}

quickcheck! {
// Helper macro to allow us to use smaller quickcheck limits under miri.
macro_rules! quickcheck_limit {
(@as_items $($i:item)*) => ($($i)*);
{
$(
$(#[$m:meta])*
fn $fn_name:ident($($arg_name:ident : $arg_ty:ty),*) -> $ret:ty {
$($code:tt)*
}
)*
} => (
quickcheck::quickcheck! {
@as_items
$(
#[test]
$(#[$m])*
fn $fn_name() {
fn prop($($arg_name: $arg_ty),*) -> $ret {
$($code)*
}
let mut quickcheck = QuickCheck::new();
if cfg!(miri) {
quickcheck = quickcheck
.gen(Gen::new(10))
.tests(10)
.max_tests(100);
}

quickcheck.quickcheck(prop as fn($($arg_ty),*) -> $ret);
}
)*
}
)
}

quickcheck_limit! {
fn contains(insert: Vec<u32>) -> bool {
let mut map = IndexMap::new();
for &key in &insert {
Expand Down Expand Up @@ -260,7 +295,7 @@ where
true
}

quickcheck! {
quickcheck_limit! {
fn operations_i8(ops: Large<Vec<Op<i8, i8>>>) -> bool {
let mut map = IndexMap::new();
let mut reference = HashMap::new();
Expand Down