Skip to content

Commit 26abede

Browse files
committed
Adds miri to CI/CD
1 parent 0a3cad3 commit 26abede

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.github/workflows/ci.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ jobs:
8888
run: sudo apt-get install libopenblas-dev gfortran
8989
- run: ./scripts/all-tests.sh "$FEATURES" ${{ matrix.rust }}
9090

91+
miri:
92+
runs-on: ubuntu-latest
93+
name: miri
94+
steps:
95+
- uses: actions/checkout@v4
96+
- uses: dtolnay/rust-toochain@nightly
97+
with:
98+
components: miri
99+
- uses: Swatinem/rust-cache@v2
100+
- name: Install openblas
101+
run: sudo apt-get install libopenblas-dev gfortran
102+
- run: ./scripts/miri-tests.sh
103+
91104
cross_test:
92105
#if: ${{ github.event_name == 'merge_group' }}
93106
runs-on: ubuntu-latest

ndarray-rand/tests/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn oversampling_without_replacement_should_panic()
5757
}
5858

5959
quickcheck! {
60+
#[cfg_attr(miri, ignore)] // Takes an insufferably long time
6061
fn oversampling_with_replacement_is_fine(m: u8, n: u8) -> TestResult {
6162
let (m, n) = (m as usize, n as usize);
6263
let a = Array::random((m, n), Uniform::new(0., 2.));
@@ -84,6 +85,7 @@ quickcheck! {
8485
}
8586
}
8687

88+
#[cfg_attr(miri, ignore)]
8789
#[cfg(feature = "quickcheck")]
8890
quickcheck! {
8991
fn sampling_behaves_as_expected(m: u8, n: u8, strategy: SamplingStrategy) -> TestResult {

scripts/miri-tests.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
set -x
4+
set -e
5+
6+
# We rely on layout-dependent casts, which should be covered with #[repr(transparent)]
7+
# This should catch if we missed that
8+
RUSTFLAGS="-Zrandomize-layout"
9+
10+
# General tests
11+
cargo miri test -v --no-default-features
12+
cargo miri test -v -p ndarray -p ndarray-rand --lib --tests
13+
14+
# BLAS tests
15+
cargo miri test -p ndarray --lib -v --features blas
16+
cargo miri test -p blas-mock-tests -v
17+
cargo miri test -p blas-tests -v --features blas-tests/openblas-system
18+
cargo miri test -p numeric-tests -v --features numeric-tests/test_blas
19+
20+
# Examples
21+
cargo miri test --examples

0 commit comments

Comments
 (0)