tarpaulin icon indicating copy to clipboard operation
tarpaulin copied to clipboard

`should_panic` marker not honored in README.md doctest

Open nu11ptr opened this issue 2 years ago • 3 comments

When using a doctest in a README.md file marked with should_panic, tarpaulin executes it but does not seem to parse out the should_panic as it ends in failure. Removing the should_panic flag (and removing the failing assert) and it passes as expected.

My repo is very small so can probably be used as a reproducible sample:

README: https://github.com/nu11ptr/assert_unordered/blame/master/README.md#L25

Code that triggers README test: https://github.com/nu11ptr/assert_unordered/blob/master/src/lib.rs#L40

I was expecting (or at least hoping) the test would pass like it does when executed with cargo test

nu11ptr avatar Apr 16 '22 14:04 nu11ptr

This looks like a duplicate of https://github.com/xd009642/tarpaulin/issues/924 and this comment explains what is happening https://github.com/xd009642/tarpaulin/issues/924#issuecomment-1005258371 aside from better upstream support in rustc or the attribute finding code expanding preprocessor includes of text the only approach I could think of would be a hacky flag like --doctests-always-pass

xd009642 avatar Apr 16 '22 14:04 xd009642

Appreciate the fast response. Other than disabling my README test, any ideas for how to get tarpaulin to just skip this test, but not cargo test? Otherwise I'll probably just have to disable the README test for now, thx.

nu11ptr avatar Apr 16 '22 19:04 nu11ptr

There's the ignore attribute on doc tests, as described in the doctest docs. Other than that not running tarpaulin for doc tests

xd009642 avatar Apr 16 '22 19:04 xd009642

Going to close this as duplicated, I also don't see myself supporting the include macros for doc tests in the near future (unfortunately)

xd009642 avatar Jan 26 '23 21:01 xd009642