From 0d50118e44f09144d45ef8cc257de3f2fb9c1821 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Tue, 17 Nov 2020 13:47:40 -0600 Subject: [PATCH] Run tests under miri on CI --- .github/workflows/ci.yaml | 15 +++++++++++++++ vm/src/builtins/dict.rs | 6 +++--- vm/src/pyobjectrc.rs | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f60631075..a29e303e6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -161,6 +161,21 @@ jobs: run: python -m pip install flake8 - name: run lint run: flake8 . --count --exclude=./.*,./Lib,./vm/Lib --select=E9,F63,F7,F82 --show-source --statistics + miri: + name: Run tests under miri + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + components: miri + override: true + - name: Run tests under miri + # miri-ignore-leaks because the type-object circular reference means that there will always be + # a memory leak, at least until we have proper cyclic gc + run: MIRIFLAGS='-Zmiri-ignore-leaks' cargo +nightly miri test -p rustpython-vm -- miri_test wasm: name: Check the WASM package and demo diff --git a/vm/src/builtins/dict.rs b/vm/src/builtins/dict.rs index d716a2fd0..9d45bfaff 100644 --- a/vm/src/builtins/dict.rs +++ b/vm/src/builtins/dict.rs @@ -597,7 +597,7 @@ macro_rules! dict_iterator { let s = if let Some(_guard) = ReprGuard::enter(vm, zelf.as_object()) { let mut str_parts = vec![]; for (key, value) in zelf.dict.clone() { - let s = vm.to_repr(&$result_fn(vm, key, value))?; + let s = vm.to_repr(&($result_fn)(vm, key, value))?; str_parts.push(s.borrow_value().to_owned()); } format!("{}([{}])", $class_name, str_parts.join(", ")) @@ -694,7 +694,7 @@ macro_rules! dict_iterator { match zelf.dict.entries.next_entry(&mut position) { Some((key, value)) => { zelf.position.store(position); - Ok($result_fn(vm, key, value)) + Ok(($result_fn)(vm, key, value)) } None => Err(vm.new_stop_iteration()), } @@ -743,7 +743,7 @@ macro_rules! dict_iterator { match zelf.dict.len().checked_sub(count) { Some(mut pos) => { let (key, value) = zelf.dict.entries.next_entry(&mut pos).unwrap(); - Ok($result_fn(vm, key, value)) + Ok(($result_fn)(vm, key, value)) } None => { zelf.position.store(std::isize::MAX as usize); diff --git a/vm/src/pyobjectrc.rs b/vm/src/pyobjectrc.rs index 80115a0af..f60718929 100644 --- a/vm/src/pyobjectrc.rs +++ b/vm/src/pyobjectrc.rs @@ -517,7 +517,7 @@ pub(crate) fn init_type_hierarchy() -> (PyTypeRef, PyTypeRef) { mod tests { use super::*; #[test] - fn test_type_initialization() { + fn miri_test_type_initialization() { let _ = init_type_hierarchy(); } }