taiki-e / cargo-llvm-cov

Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).
Apache License 2.0
858 stars 57 forks source link

Allow running individual tests with coverage #347

Open Pzixel opened 4 months ago

Pzixel commented 4 months ago

There is a workaround currently to run individual tests and get coverage for them:

 cargo llvm-cov --lcov --output-path lcov.info  -- my::super::model::test_name --exact --nocapture

I think it is either worth documenting this as a recommended way of running individual tests or add an explicit option for this. Currently cargo-llvm-cov looks highly tuned for CI workflow while I think local development flow is also valuable, which you want to run one or a couple of tests at once, not the entire test suite.

taiki-e commented 4 months ago

I would accept a PR to improve docs. (It would be better to add it before or after the section on VSCode.)

It would not be so easy to add a dedicated command for this purpose. In fact, I don't think Cargo had it either. That said, if someone has a concrete idea I can consider accepting it.

There is a workaround

Currently cargo-llvm-cov looks highly tuned for CI workflow

To be fair, we need the same thing when using cargo, right? it sounds a bit unfair to claim that this is "highly tuned for CI" for a tool that just doesn't support what cargo itself doesn't support as well.

(I guess it would also be possible to do the equivalent by adjusting the rust-analyzer's cargo test command settings.)

Pzixel commented 4 months ago

To be fair, we need the same thing when using cargo, right? it sounds a bit unfair to claim that this is "highly tuned for CI" for a tool that just doesn't support what cargo itself doesn't support as well.

Well for cargo purpose -- part that goes to rustc does the trick. With cargo-llvm-cov it's a bit less obvious and also it prints the large table with 0% coverage for all the tests except one that ran. if we could skip them that would be nice, but it's more of QoL feature which doesn't actually break anything, just annoys a little bit.