-
-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify behaviour and interplay of --run-types
, --tests
, --doc
, --all-targets
, etc.
#1302
Comments
So tarpaulin actually matches
Allowing The error with all-targets is likely due to over-enthusiastically passing flags into Hopefully this clears up some of the initial questions or provides some clarity. Tomorrow I'll try to find some time to go over in more detail and actually address the issues in the docs and make |
Thanks for the fast reply! The help for $ cargo test --help | grep -C2 -- '--all-targets'
--benches Test all benches
--offline Run without accessing the network
--all-targets Test all targets
--config <KEY=VALUE> Override a configuration value
--doc Test only this library's documentation so that would've helped clear up the confusion. Perhaps a version mismatch (I have v1.69.0). It's helpful to see that tarpaulin mirrors that, thanks. I agree about being pragmatic in the |
Yeah so the help for cargo test doesn't include it, it's only in the cargo book hosted online. Maybe worth raising an issue on rust-lang/cargo if you feel the CLI help text could stand to be improved. I'm adding I've also tracked down the issue with |
Came here in trying to find out how to run overall coverage, aka doc, unit and perhaps more tests combined.
Initially I found this comment in #13 which says:
I'm not sure how to get this working. Perhaps things changed in the four years since. #850 is tightly related but the below differs, and I didn't want to comment in an old, closed issue.
I am working with:
and have a sample project:
with the
lib.rs
as:and
Cargo.toml
:Now,
cargo tarpaulin --doc
reports 50%,cargo tarpaulin --tests
reports 50% as well, and lastlycargo tarpaulin --doc --tests
gives 100% coverage. Great, works! But how does--run-type AllTargets
work? Its behaviour isn't clear to me:cargo tarpaulin --run-types doctests
tests only doctests, which is fine. Reports 50% coverage.cargo tarpaulin --run-types tests
tests only unit tests, also fine. Gives 50% coverage.cargo tarpaulin --run-types AllTargets
, contrary to the abovecargo tarpaulin --doc --tests
, exercises only the unit, not the doc test, giving 50% as well, which is unexpected.Run the above examples with
--out html
to see the coverage "flip around" between the one unit and the one doc test.Another thing of note is how the help output is written, where it says:
but also, for example:
As far as I understand one could run
cargo tarpaulin --tests --doc --examples
to run all three and combine results. However, only for the--doc
option does it sayonly
, which I guess is misleading?Lastly, either a hint that these options combine (which ones exactly then?
--tests
,--doc
,--examples
, ...--benches
I guess? Did I miss anything?) would be helpful, and/or a flag for running everything combined (is this was--run-types AllTargets
is designed for)?I can offer looking into clearing this up in a PR, but the
--run-types
arg I'm not clear on yet. It seems related to other, 'single' flags:tarpaulin/src/cargo.rs
Lines 535 to 544 in 8c876b1
In fact, passing just
--all-targets
errors out, which is quite unexpected behaviour on the CLI (passing a single flag shouldn't error out, as it can't contradict anything; maybe ignore if tarpaulin already passes it tocargo test
?):The help output doesn't warn of this potential behaviour:
Thanks for putting together this crate, it works really well! Just at this point I reckon the docs can be tad clearer.
The text was updated successfully, but these errors were encountered: