Coverage reports in CI
CLAP coverage reporting is compiler-instrumented coverage, not a Python approximation. Use GCC with gcov or Clang with llvm-cov in PATH. Zig coverage is rejected explicitly because the pinned Zig runtime does not ship usable LLVM gcov runtime pieces.
Generate reports
Direct tests:
clap test test_one.c test_two.c --coverage-report coverage --junit-xml test-results.xmlCMake/CTest projects:
clap test . --coverage-report coverage --junit-xml test-results.xmlA direct executable can also be measured with clap run ... --coverage-report coverage. CMake build/cmake invocations instrument objects, but a test or executable run is still required before .gcda data exists.
Outputs
A report directory contains:
| File | Consumer |
|---|---|
coverage.xml | Cobertura-compatible CI coverage ingestion |
index.html | small self-contained human-readable summary for build artifacts |
coverage-summary.json | scripts, agents, and custom dashboards |
summary.txt | humans reading job logs/artifacts |
*.gcov | detailed compiler-native annotated source output |
Reports include line coverage and, when the compiler reports branches, branch coverage. Cobertura line elements for branchy lines include condition-coverage. Multiple independent direct test binaries use instrumented line/branch instance aggregation; shared headers can be counted once per test binary. XML merge across reports conservatively keeps the maximum hit/branch counts for duplicate source lines.
CI usage pattern
A portable CI job shape is:
python -m pip install clap-compiler
clap bootstrap --warmup
clap test . --system --coverage-report coverage --junit-xml test-results.xml --coverage-fail-under 80 --coverage-branch-fail-under 60--coverage-fail-under PERCENT fails the command when total line coverage is below the threshold. --coverage-branch-fail-under PERCENT does the same for compiler-reported branch coverage and fails if branch data is missing. Thresholds require --coverage-report, because otherwise there is no machine-checked summary to enforce. They work for direct runs, aggregated multi-test reports, and CMake/CTest reports.
Use --system when coverage is required because the pinned Zig toolchain is not a supported coverage backend. On Linux install GCC/gcov or Clang/llvm-cov through the platform package manager. On macOS use Xcode Command Line Tools; gcc is normally an Apple Clang alias, so llvm-cov must also be visible. On Windows use a real GCC/MinGW installation that includes both gcc and gcov in PATH; native validation used a Scoop winlibs MinGW toolchain. MSVC and the pinned Zig toolchain are not coverage backends.
Upload coverage/ as a CI artifact. If the CI system understands Cobertura, point its coverage ingestion at coverage/coverage.xml; point test-result ingestion at test-results.xml. Keep summary.txt in the same artifact as a quick human-readable audit trail.
Interpreting the data
line_rateis covered instrumented lines divided by valid instrumented lines.branch_rateis branches taken at least once divided by compiler-reported branches.- A line can have full line coverage and partial branch coverage.
- CMake compiler-probe files under
CompilerId*are excluded. - Coverage percentages are measurements of the executed test suite, not proof of correctness.
Common failures
no coverage data files found means compilation was instrumented but the executable/tests did not run afterward. Clang coverage reports require llvm-cov means the compiler worked but the report tool is missing. For other failures, see TROUBLESHOOTING.md.