You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Tarpaulin doesn't recognise a line as covered even though it is. In particular, in the example tarpaulin says that the line 5 is not covered.
This does not happen if the call to the async function that I want to test happens outside a catch_unwind block. I can't just put it outside a catch_unwind block because my test requires some setup and teardown, and I have to make sure that even if the test fails, I do the teardown, and I'm using the catch_unwind block as suggested here.
This does not happen if, even if inside a catch_unwind block, the function is sync, as shown in the example
To Reproduce
[./Cargo.toml]
[package]
name = "tarpaulin-bug-async"version = "0.1.0"edition = "2021"
[dependencies]
tokio = { version = "1", features = ["full"] }
[./src/lib.rs]
pubfnsome_function() -> u8{127}pubasyncfnsome_async_function() -> u8{127}#[cfg(test)]mod tests {usesuper::{some_async_function, some_function};#[tokio::test]asyncfnasync_test(){// This test should cover line 5, but tarpaulin doesn't recognise that.// It does recognise it if I just do `assert_eq!(some_async_function().await, 127);`// without the `catch_unwind` but I do need the catch_unwind because// the actual async_test for my library involves a bit of setup and// teardown (see https://medium.com/@ericdreichert/test-setup-and-teardown-in-rust-without-a-framework-ba32d97aa5ab )let result = std::panic::catch_unwind(|| async{assert_eq!(some_async_function().await, 127);});assert!(result.is_ok())}#[test]fntest(){// Even though here there's a catch_unwind just like the async_test, tarpaulin// does recognise that this test tests line 1, unlike what happens with// the async_testlet result = std::panic::catch_unwind(|| {assert_eq!(some_function(), 127);});assert!(result.is_ok())}}
On calling cargo tarpaulin is the following
Aug 21 14:56:10.009 INFO cargo_tarpaulin::config: Creating config
Aug 21 14:56:10.042 INFO cargo_tarpaulin: Running Tarpaulin
Aug 21 14:56:10.042 INFO cargo_tarpaulin: Building project
Aug 21 14:56:10.042 INFO cargo_tarpaulin::cargo: Cleaning project
Compiling libc v0.2.132
Compiling autocfg v1.1.0
Compiling proc-macro2 v1.0.43
Compiling quote v1.0.21
Compiling unicode-ident v1.0.3
Compiling cfg-if v1.0.0
Compiling parking_lot_core v0.9.3
Compiling log v0.4.17
Compiling syn v1.0.99
Compiling smallvec v1.9.0
Compiling scopeguard v1.1.0
Compiling memchr v2.5.0
Compiling pin-project-lite v0.2.9
Compiling bytes v1.2.1
Compiling once_cell v1.13.1
Compiling lock_api v0.4.7
Compiling tokio v1.20.1
Compiling signal-hook-registry v1.4.0
Compiling socket2 v0.4.4
Compiling num_cpus v1.13.1
Compiling mio v0.8.4
Compiling parking_lot v0.12.1
Compiling tokio-macros v1.8.0
Compiling tarpaulin-bug-async v0.1.0 (/home/[redacted, path to working directory]/tarpaulin-bug-async)
Finished test [unoptimized + debuginfo] target(s) in 11.91s
Executable unittests src/lib.rs (target/debug/deps/tarpaulin_bug_async-54856c8466d7b03f)
Aug 21 14:56:22.084 INFO cargo_tarpaulin::process_handling::linux: Launching test
Aug 21 14:56:22.085 INFO cargo_tarpaulin::process_handling: running /home/[redacted, path to working directory]/tarpaulin-bug-async/target/debug/deps/tarpaulin_bug_async-54856c8466d7b03f
running 2 tests
test tests::test ... ok
test tests::async_test ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
Aug 21 14:56:22.723 INFO cargo_tarpaulin::report: Coverage Results:
|| Uncovered Lines:
|| src/lib.rs: 5
|| Tested/Total Lines:
|| src/lib.rs: 8/9
||
88.89% coverage, 8/9 lines covered
I'm reproducing this on Linux Mint 20.3, and this is the output of uname -a
Linux lenovo-ideapad5 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
The version of rustc used is rustc 1.61.0 (fe5b13d68 2022-05-18)
Expected behavior
The line 5 should be counted as covered, so the Total Lines for src/lib.rs should be 8/8, and the coverage should be 100% instead of 88.89%
The text was updated successfully, but these errors were encountered:
Describe the bug
Tarpaulin doesn't recognise a line as covered even though it is. In particular, in the example tarpaulin says that the line
5
is not covered.This does not happen if the call to the async function that I want to test happens outside a catch_unwind block. I can't just put it outside a catch_unwind block because my test requires some setup and teardown, and I have to make sure that even if the test fails, I do the teardown, and I'm using the catch_unwind block as suggested here.
This does not happen if, even if inside a catch_unwind block, the function is sync, as shown in the example
To Reproduce
[./Cargo.toml]
[./src/lib.rs]
On calling
cargo tarpaulin
is the followingI'm reproducing this on Linux Mint 20.3, and this is the output of
uname -a
Linux lenovo-ideapad5 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
The version of rustc used is
rustc 1.61.0 (fe5b13d68 2022-05-18)
Expected behavior
The line
5
should be counted as covered, so the Total Lines forsrc/lib.rs
should be8/8
, and the coverage should be100%
instead of88.89%
The text was updated successfully, but these errors were encountered: