#coverage #format #convert #llvm-cov #cargo #codecov #utility

app cargo-llvm-codecov-converter

conversion utility from llvm-cov format to codecov format

1 unstable release

0.1.0 Jan 1, 2021

#318 in Profiling

MIT license

15KB
353 lines

cargo-llvm-codecov-converter

Convert from llvm-cov format to codecov format

installation: cargo install cargo-llvm-codecov-converter

converts llvm-cov json formatted output from the llvm-cov export tool into the codecov custom coverage format via Stdin and Stdout

for example to calculate coverage for rust code:

export LLVM_PROFILE_FILE="target/debug/coverage/<my-crate>-%m.profraw"

# build the test binary with coverage instrumentation
executables=$(RUSTFLAGS="-Zinstrument-coverage" cargo test --tests --no-run --message-format=json | jq -r "select(.profile.test == true) | .executable")

# run instrumented tests
$executables

# combine profraw files
cargo profdata -- merge -sparse target/debug/coverage/<my-crate>-*.profraw -o target/debug/coverage/<my-crate>.profdata

# collect coverage
cargo cov -- export $executables \
    --instr-profile=target/debug/coverage/<my-crate>.profdata \
    --ignore-filename-regex="(.*\.cargo/registry/.*)|(.*\.rustup/.*)|(.*test.*)" \
    --skip-functions \
    | cargo llvm-codecov-converter > target/debug/coverage/<my-crate>.json

note the pipe into cargo llvm-codecov-converter

Dependencies

~1.9–3MB
~61K SLoC