Skip to content

Commit

Permalink
Add tests about anyhow and backtrace (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy authored Aug 31, 2022
1 parent 913b17d commit ba1d3ee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fastrand = "^1.3"
[[example]]
name = "containers"
path = "tests/containers.rs"
required-features = ["anyhow", "backtrace"]

[features]
default = []
Expand Down
11 changes: 11 additions & 0 deletions tests/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit ba1d3ee

Please sign in to comment.