Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Coverage

cmakefmt treats coverage as a contributor tool, not as a vanity number.

The goal is simple: make it obvious which parts of the formatter are exercised by the default test suite, and make it easy to inspect the results locally and in CI.

What The Coverage Workflow Runs

GitHub Actions runs coverage with cargo llvm-cov on the default test suite:

cargo llvm-cov clean --workspace
cargo llvm-cov --workspace --all-targets --summary-only
cargo llvm-cov report --workspace --all-targets --html

That means coverage includes:

  • library code under src/
  • the CLI binary under src/main.rs
  • unit tests
  • integration tests

The workflow publishes:

  • a text summary in the GitHub Actions job summary
  • the raw summary as an artifact
  • an HTML report as an artifact for line-by-line inspection

What Coverage Is Not Trying To Measure

Coverage is helpful, but it is not the whole quality story. cmakefmt still leans heavily on:

  • snapshot tests for formatter behavior
  • idempotency checks
  • real-world corpus tests
  • performance benchmarks

High coverage with weak corpus coverage would still be a bad trade.

Local Coverage

Install cargo-llvm-cov once:

cargo install cargo-llvm-cov

Then run coverage locally:

cargo llvm-cov clean --workspace
cargo llvm-cov --workspace --all-targets --summary-only
cargo llvm-cov report --workspace --all-targets --html

The HTML report is written under target/llvm-cov/html/.

Reading The Results

When coverage changes, pay attention to where the delta lands:

  • parser and formatter core paths matter more than trivial getters
  • config discovery and CLI integration matter because they are user-facing
  • new CLI features should ship with direct integration coverage
  • performance-sensitive hot paths should still keep behavior tests around them

In short: coverage is a guide to missing tests, not a substitute for good test design.