taiki-e / cargo-llvm-cov

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

Why is the target directory cleared when CI is set? #78

Closed fourbytes closed 3 years ago

fourbytes commented 3 years ago

I've just moved our projects from Tarpaulin to cargo-llvm-cov and coverage is much more accurate. I noticed however that our caching stopped working and it took me a good while to figure out why, but it seems to be due to this line which cleans the target directory when the CI environment variable is set.

Is there a particular reason for this? If I manually unset CI I am able to get caching working nicely again without recompiling hundreds of dependencies. Imho it would be better to leave it up to the user with an --always-clean flag or similar.

taiki-e commented 3 years ago

The current heuristics for build artifacts cleanup are a bit rough.

So, the right way here is probably to get the names of the crates to be measured for coverage and remove the build artifacts for those crates using (relatively recently added) --package option of cargo clean.

EDIT: The answer to the original question "Is there a particular reason for this?" is: "This is due to a bit rough heuristic to avoid false positives/false negatives".

fourbytes commented 3 years ago

Gotcha, removing artifacts for only crates being measured seems like a great way to go. Thanks.

taiki-e commented 3 years ago

Solved in v0.1.4.