taiki-e / cargo-llvm-cov

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

Option to show uncovered lines in the command-line output #142

Closed vmiklos closed 2 years ago

vmiklos commented 2 years ago

Now that --fail-under-lines works, my only remaining pain point with cargo llvm-cov is that the iteration cycle (when writing tests for uncovered code) is a bit complex, compared to other coverage tools I saw before. The text output is nice, but it even shows covered lines, so it's very verbose. The command-line output is the other extreme: it's just a summary, it doesn't show you exactly what lines are uncovered.

E.g. Python's coverage.py has a simple way to just point out the uncovered lines, one line / filename, like this:

foo.py: 12, 22
bar.py: 32, 42

coverage.py calls this option --show-missing. I think that's a nice middle ground that is sometimes useful to people.

Would you accept a patch to add a --show-missing-lines (or similarly named) optional bool switch that would print such info at the end?

I expect doing such analysis based on the llvm-cov json output is not too hard (when limited to line coverage), we just would need to detect lines which have matching segments but all of them are the "could have a count, but doesn't" case.

taiki-e commented 2 years ago

I would accept a PR to add this.