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

`object_files` includes upstream build scripts #154

Closed davidhewitt closed 2 years ago

davidhewitt commented 2 years ago

Looking at the coverage failure in https://github.com/PyO3/pyo3/pull/2356

I noticed that a lot of files passed as -object are build scripts for upstream dependencies:

target\debug\build\ahash-86b398e50bc5cdf8\build-script-build.exe
target\debug\build\ahash-86b398e50bc5cdf8\build_script_build-86b398e50bc5cdf8.exe
target\debug\build\anyhow-3ca1fe7ae176b565\build-script-build.exe
target\debug\build\anyhow-3ca1fe7ae176b565\build_script_build-3ca1fe7ae176b565.exe
target\debug\build\anyhow-3eee420b052878e1\build-script-build.exe
target\debug\build\anyhow-3eee420b052878e1\build_script_build-3eee420b052878e1.exe
target\debug\build\cast-91fd05a37bec76e5\build-script-build.exe
target\debug\build\cast-91fd05a37bec76e5\build_script_build-91fd05a37bec76e5.exe
target\debug\build\cast-998c8e4aafe34f1e\build-script-build.exe
target\debug\build\cast-998c8e4aafe34f1e\build_script_build-998c8e4aafe34f1e.exe
target\debug\build\crossbeam-epoch-842aa957d6ccdb11\build-script-build.exe
target\debug\build\crossbeam-epoch-842aa957d6ccdb11\build_script_build-842aa957d6ccdb11.exe
target\debug\build\crossbeam-utils-1bf3f6f44b031900\build-script-build.exe
target\debug\build\crossbeam-utils-1bf3f6f44b031900\build_script_build-1bf3f6f44b031900.exe
target\debug\build\eyre-0d0ae49eedee20b4\build-script-build.exe
target\debug\build\eyre-0d0ae49eedee20b4\build_script_build-0d0ae49eedee20b4.exe
target\debug\build\getrandom-39f03a4df4e08170\build-script-build.exe
target\debug\build\getrandom-39f03a4df4e08170\build_script_build-39f03a4df4e08170.exe
target\debug\build\indexmap-e74cbdf7d03137b1\build-script-build.exe
target\debug\build\indexmap-e74cbdf7d03137b1\build_script_build-e74cbdf7d03137b1.exe
target\debug\build\libc-309b983f2e20f08e\build-script-build.exe
target\debug\build\libc-309b983f2e20f08e\build_script_build-309b983f2e20f08e.exe
target\debug\build\libc-927850822b4d32e6\build-script-build.exe

I guess it must be impossible for these to actually contribute to coverage? I wonder if it makes sense in cargo-llvm-cov to filter out these build scripts? I don't think it's as trivial as filtering all build scripts, because it would be nice to include coverage from the build scripts of crates in the workspace.

taiki-e commented 2 years ago

I agree that the build scripts other than crates in the workspace should be excluded because it is never actually referenced.

taiki-e commented 2 years ago

Fixed in 0.3.2.

davidhewitt commented 2 years ago

Thank you so much! I reran PyO3's main pipeline and it completed successfully: https://github.com/PyO3/pyo3/runs/6316472788?check_suite_focus=true