From adbd47973e7b5c1973d512c67ab8f373556202dc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 5 Mar 2022 19:07:41 -0500 Subject: [PATCH 1/2] reduce number of tests being run under Miri --- crates/test_helpers/src/lib.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/test_helpers/src/lib.rs b/crates/test_helpers/src/lib.rs index 7edd60963817..8bf7f5ed3d2a 100644 --- a/crates/test_helpers/src/lib.rs +++ b/crates/test_helpers/src/lib.rs @@ -77,11 +77,21 @@ impl DefaultStrategy } } +#[cfg(not(miri))] +fn make_runner() -> proptest::test_runner::TestRunner { + Default::default() +} +#[cfg(miri)] +fn make_runner() -> proptest::test_runner::TestRunner { + // Only run a few tests on Miri + proptest::test_runner::TestRunner::new(proptest::test_runner::Config::with_cases(4)) +} + /// Test a function that takes a single value. pub fn test_1( f: &dyn Fn(A) -> proptest::test_runner::TestCaseResult, ) { - let mut runner = proptest::test_runner::TestRunner::default(); + let mut runner = make_runner(); runner.run(&A::default_strategy(), f).unwrap(); } @@ -89,7 +99,7 @@ pub fn test_1( pub fn test_2( f: &dyn Fn(A, B) -> proptest::test_runner::TestCaseResult, ) { - let mut runner = proptest::test_runner::TestRunner::default(); + let mut runner = make_runner(); runner .run(&(A::default_strategy(), B::default_strategy()), |(a, b)| { f(a, b) @@ -105,7 +115,7 @@ pub fn test_3< >( f: &dyn Fn(A, B, C) -> proptest::test_runner::TestCaseResult, ) { - let mut runner = proptest::test_runner::TestRunner::default(); + let mut runner = make_runner(); runner .run( &( @@ -361,24 +371,28 @@ macro_rules! test_lanes { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] + #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow fn lanes_8() { implementation::<8>(); } #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] + #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow fn lanes_16() { implementation::<16>(); } #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] + #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow fn lanes_32() { implementation::<32>(); } #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] + #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow fn lanes_64() { implementation::<64>(); } From 4023d77e39c3af4a735b8d0974414ec06d5391c7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 9 Mar 2022 09:00:46 -0500 Subject: [PATCH 2/2] run Miri on CI (but allowed to fail) --- .github/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d50dfa1be4cb..54d747647906 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,23 @@ jobs: - name: Run Clippy run: cargo clippy --all-targets --target ${{ matrix.target }} + miri: + name: "miri" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Miri + run: | + rustup toolchain install nightly --component miri + rustup override set nightly + cargo miri setup + - name: Test with Miri (failures allowed) + continue-on-error: true + run: | + cargo miri test --test i32_ops + cargo miri test --test f32_ops + cargo miri test --test cast + x86-tests: name: "${{ matrix.target_feature }} on ${{ matrix.target }}" runs-on: ${{ matrix.os }}