diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f40807a..df99803 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -386,3 +386,25 @@ jobs: echo "${{ runner.tool_cache }}/wasmtime-v24.0.0-x86_64-linux" >> $GITHUB_PATH echo "CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime run --" >> $GITHUB_ENV - run: cargo test --target wasm32-wasip1 --all -- --nocapture + + miri-test: + name: Test stacker with Miri on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - name: Install Rust nightly with Miri + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + profile: minimal + components: miri + default: true + - name: Setup Miri + run: cargo miri setup + - name: Test with Miri + run: cargo miri test -- --nocapture diff --git a/src/lib.rs b/src/lib.rs index 81d7e49..3a7c898 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,12 +169,12 @@ psm_stack_manipulation! { } no { - #[cfg(not(windows))] + #[cfg(not(all(windows, not(miri))))] fn _grow(stack_size: usize, callback: &mut dyn FnMut()) { let _ = stack_size; callback(); } - #[cfg(windows)] + #[cfg(all(windows, not(miri)))] use backends::windows::_grow; } } diff --git a/tests/simple.rs b/tests/simple.rs index bb10937..807cbf9 100644 --- a/tests/simple.rs +++ b/tests/simple.rs @@ -18,6 +18,7 @@ fn recurse(n: usize) { } #[test] +#[cfg_attr(miri, ignore)] // Too slow under Miri's interpreter fn foo() { let limit = if cfg!(target_arch = "wasm32") { 2000 diff --git a/tests/smoke.rs b/tests/smoke.rs index 2ec0de2..c9c6fb5 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -21,7 +21,7 @@ fn deep() { } } - let limit = if cfg!(target_arch = "wasm32") { + let limit = if cfg!(target_arch = "wasm32") || cfg!(miri) { 2000 } else { 256 * 1024 @@ -31,6 +31,7 @@ fn deep() { #[test] #[cfg_attr(target_arch = "wasm32", ignore)] +#[cfg_attr(miri, ignore)] // Too slow under Miri's interpreter fn panic() { fn foo(n: usize, s: &mut [u8]) { __stacker_black_box(s.as_ptr());