Code coverage
Revive measures Rust and LLVM C++ line and region coverage with cargo-llvm-cov over the same tests as make test-workspace.
Two ways to obtain a report:
- Locally:
make coverageandmake coverage-llvm-report(described below). - Per PR: apply the
measure code coveragelabel and read the bot-generated PR comment once the triggered workflow completes.
Running locally
# Install LLVM.
make install-llvm
# Or install instrumented LLVM.
make install-llvm-coverage
# ..set LLVM_SYS_221_PREFIX to a compatible LLVM build..
# Run coverage and generate revive Rust report.
make coverage
# Generate a separate LLVM C++ report if needed, if
# instrumented LLVM was used for `make coverage`.
make coverage-llvm-report
# Print clickable links to all accumulated HTML reports detected
# (they're grouped by timestamps) to easily view them in the browser.
make coverage-browse
The target:
- Builds and tests the workspace under cargo-llvm-cov with
--ignore-run-failso partial coverage lands even when test binaries exit non-zero. - Writes a browsable HTML report into a timestamped run directory (
coverage-reports/<stamp>/revive/orcoverage-reports/<stamp>/llvm/).
Resource requirements and troubleshooting
make coverage bakes in two defaults that keep instrumented runs tractable:
- It drops DWARF with
CARGO_PROFILE_DEV_DEBUG=0since coverage line data lives in the binaries’__llvm_covmapsections. - It bounds profile output with
LLVM_PROFILE_FILE_NAME=revive-%4m.profraw. The default pattern contains%p, writing one raw profile per process. With an instrumented LLVM this could exceed tens of gigabytes of raw profiles in a full run. The%4mmerge pool makes processes merge their counters into a handful of files instead.
Even with those defaults, plan for:
- Disk space:
- Building instrumented LLVM and running an instrumented
make coveragestill needs tens of gigabytes of disk space.
- Building instrumented LLVM and running an instrumented
- LLVM link memory (
make install-llvm-coverage):- If a link step gets OOM-killed, rerun with capped parallelism (e.g.
JOBS=1) to serialize the links. The rerun resumes incrementally.
- If a link step gets OOM-killed, rerun with capped parallelism (e.g.
- Test-binary link memory (
make coverage):- If a link gets OOM-killed, rerun with
RUSTFLAGS="-C link-arg=-fuse-ld=lld"(or additionally with capped parallelism, e.g.CARGO_BUILD_JOBS=1). GNU ld holds every input object and the coverage mapping of the entire dependency closure in memory at once. lld links with a smaller peak.
- If a link gets OOM-killed, rerun with
- Test-run memory (
make coverage):- Each concurrently running test spawns an instrumented resolc. On memory-constrained machines cap it with
RUST_TEST_THREADS=4. This throttles test execution only, not compilation.
- Each concurrently running test spawns an instrumented resolc. On memory-constrained machines cap it with