taiki-e / cargo-llvm-cov

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

Add selective coverage instrumentation for crates #387

Open 0xdeafbeef opened 3 hours ago

0xdeafbeef commented 3 hours ago

This tool already has --exclude-from-report, does it make sense to add black/white lists for toggling instrumentation on and off? Like --enable-coverage-for crate1 --enable-coverage-for crate2 or --disable coverage-for tokio

taiki-e commented 3 hours ago

I guess you can use --dep-coverage (https://github.com/taiki-e/cargo-llvm-cov/pull/353).

    --dep-coverage <NAME>
            Show coverage of the specified dependency instead of the crates in the current workspace. (unstable)
0xdeafbeef commented 2 hours ago

I guess you can use --dep-coverage (#353).

    --dep-coverage <NAME>
            Show coverage of the specified dependency instead of the crates in the current workspace. (unstable)

Seems not. I want to disable coverage instrumentation for some heavy math libs and tokio, otherwise tests fail because some components time out. It can be done here, if I read code correctly. https://github.com/taiki-e/cargo-llvm-cov/blob/8a8fd85cfb60785ff8d1220090903c6ea6040c36/src/main.rs#L177 I can send a pr if it makes sense

taiki-e commented 1 hour ago

My understanding is that excluding the application of -C instrument-coverage in a particular crate, or applying it only to a particular crate, is not yet supported (https://github.com/rust-lang/rfcs/pull/3310), but if there is another way that works, I would like to accept it.