From ba1d3ee8e6d12b37d8ca63c1c13a8ff563aa5625 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Wed, 31 Aug 2022 21:25:36 +0800 Subject: [PATCH] Add tests about anyhow and backtrace (#26) --- .github/workflows/valgrind.yml | 11 +++++++++-- Cargo.toml | 1 + tests/containers.rs | 11 +++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 42daee6..33aeec0 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -17,14 +17,21 @@ jobs: toolchain: nightly override: true + # - name: Install valgrind + # run: sudo apt install -y valgrind + - name: Install valgrind - run: sudo apt install -y valgrind + run: | + sudo apt update && sudo apt install -y libclang-dev libc6-dbg \ + && wget -O valgrind.tar.bz2 https://sourceware.org/pub/valgrind/valgrind-3.19.0.tar.bz2 \ + && mkdir valgrind && tar -xvjf valgrind.tar.bz2 -C valgrind --strip-components=1 \ + && cd valgrind && ./configure && make && sudo make install - name: Run cargo build uses: actions-rs/cargo@v1 with: command: build - args: --example containers + args: "--example containers --features 'anyhow backtrace'" - name: Run valgrind run: valgrind --error-exitcode=1 --leak-check=full ./target/debug/examples/containers diff --git a/Cargo.toml b/Cargo.toml index bd6a492..b8a9a33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ fastrand = "^1.3" [[example]] name = "containers" path = "tests/containers.rs" +required-features = ["anyhow", "backtrace"] [features] default = [] diff --git a/tests/containers.rs b/tests/containers.rs index 78197fe..61abf35 100644 --- a/tests/containers.rs +++ b/tests/containers.rs @@ -163,8 +163,19 @@ fn main() { assert_eq!(0xfe112233_i64, u32_into_dart.value.as_int64); } } + + assert!(isolate.post(return_anyhow_error())); + assert!(isolate.post(return_backtrace())); + + println!("all done!"); } +fn return_anyhow_error() -> anyhow::Result<()> { + Err(anyhow::anyhow!("sample error")) +} + +fn return_backtrace() -> backtrace::Backtrace { backtrace::Backtrace::new() } + #[cfg(test)] mod tests { #[test]