-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed as not planned
Closed as not planned
Copy link
Labels
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Description
This is a feature request (tangentially related to #4865) for cargo to include an integration test that ensures that this method of building code with coverage measurement enabled continues to work in future versions.
Here's documentation of how I currently do this for the sct and rustls projects:
Prerequisites: a compatible llvm installation, lcov, nightly rustc
- Clean up:
cargo cleanand delete all.gcdaand.gcnointermediate files - Build: run
cargo rustc --all-features --profile test --lib, withRUSTC_WRAPPERset to a shell script that addsCOVERAGE_OPTIONSto the rustc invocation for a specific crate build (see below). - Execute the library unit tests program that now exists, eg
./target/debug/sct-43d2a05ec780a9bc - Use lcov to extract coverage data from resulting gcno files: run
lcov --gcov-tool ./admin/llvm-gcov --rc lcov_branch_coverage=1 --rc lcov_excl_line=assert --capture --directory . --base-directory . -o sct.info - Merge all
.infofiles into onecoverage.info: runlcov --gcov-tool ./admin/llvm-gcov --rc lcov_branch_coverage=1 --rc lcov_excl_line=assert --add sct.info -o coverage.info - Trim
coverage.infoto remove uninteresting sources: runlcov --gcov-tool ./admin/llvm-gcov --rc lcov_branch_coverage=1 --rc lcov_excl_line=assert --extract coverage.info /home/full/path/to/sct/src/\* -o final.info
My RUSTC_WRAPPER program is:
#!/bin/bash -e
get_crate_name()
{
while [[ $# -gt 1 ]] ; do
v=$1
case $v in
--crate-name)
echo $2
return
;;
esac
shift
done
}
case $(get_crate_name "$@") in
sct)
EXTRA=$COVERAGE_OPTIONS
;;
*)
;;
esac
exec "$@" $EXTRA
admin/llvm-gcov is:
#!/bin/sh -e
llvm-cov gcov $*
This method works in cargo 0.23.0 (61fa02415 2017-11-22) but is broken in cargo 0.25.0-nightly (e08f31018 2017-12-24) (and not just due to #4865).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`