Tarpaulin: panics stdout are not captured for doc tests

Created on 13 Feb 2020  ·  3Comments  ·  Source: xd009642/tarpaulin

The following code is succeeding according to tarpaulin, but the panic is not captured and Error: "Test failed during run" is printed:

/// ```should_panic
/// use paulin::hello;
///
/// hello();
/// ```
pub fn hello() {
    panic!("hello");
}

cargo tarpaulin --run-types Doctests

[INFO tarpaulin] Running Tarpaulin
[INFO tarpaulin] Building project
[INFO tarpaulin] Running doctests

running 1 test
test src/lib.rs - hello (line 1) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

[INFO tarpaulin] Launching test
[INFO tarpaulin] running /media/hdd/home/projects/paulin/target/doctests/lib_rs_1/rust_out
thread 'main' panicked at 'hello', src/lib.rs:7:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[INFO tarpaulin] Coverage Results:
|| Tested/Total Lines:
|| src/lib.rs: 3/3
|| 
100.00% coverage, 3/3 lines covered
Error: "Test failed during run"

documentation of should_panic attribute.

bug

Most helpful comment

@Luro02 I've not got a fix for this in my doctest improvements and it will be in the next release :tada:

All 3 comments

hmm I'm not sure if I can get the attribute from the doc comments... They're not really part of the AST and there are no guarantees on how the doctest code is generated. A temporary solution might be using the --ignore-panics flag otherwise I'm going to have to think about how to handle this

@Luro02 I've not got a fix for this in my doctest improvements and it will be in the next release :tada:

New version now released with a fix for this. Anymore doctest issues let me know in #455 :+1:

Was this page helpful?
0 / 5 - 0 ratings