Skip to content

Add --coverage (gcov instrumentation + gcovr report) - #62

Merged
chen3feng merged 1 commit into
mainfrom
feat/coverage
Jul 3, 2026
Merged

Add --coverage (gcov instrumentation + gcovr report)#62
chen3feng merged 1 commit into
mainfrom
feat/coverage

Conversation

@chen3feng

Copy link
Copy Markdown
Contributor

Wave-2 item from #54 (--gcov is deprecated → stays ignored).

What

--coverage instruments the build for gcov coverage (the gcc/clang --coverage driver flag on compile and link), in its own build-dir variant build_<profile>_coverage (composing before any sanitizer tag, matching Blade's variant suffix). Threaded through Options/plan/buildDirFor; honored by build/test/run/clean/dump.

Report

After blade test --coverage, the runner reports via gcovr (best-effort — warns, never fails, if gcovr is absent). Matching Blade's coverage.py:

  • clang gcov data is read with llvm-cov gcov; on macOS via xcrun (Apple's c++ is clang but the name doesn't say so — detected via --version — and its data needs the matching llvm-cov).
  • coverage_config.exclude globstar patterns → gcovr -e regexes.
  • macOS/llvm-cov emits absurd "suspicious" hit counts (gcc bug 68080), so the suspicious-hits threshold is raised to keep the report clean.

Verified on flare (macOS/clang)

test //flare/base:chrono_test --coverage → builds into build_release_coverage, runs, prints the gcovr summary (TOTAL … 12%). Unit tests cover the build-dir variants (incl. build_release_coverage_asan+ubsan) and the glob→regex translation.

Refs #54 (Wave 2).

🤖 Generated with Claude Code

--coverage instruments the build for gcov coverage (the gcc/clang
`--coverage` driver flag on compile and link), in its own build-dir
variant build_<profile>_coverage (composing before any sanitizer tag,
matching Blade's variant suffix). Like sanitizers, it's threaded through
Options/plan/buildDirFor and honored by build/test/run/clean/dump.
(--gcov is deprecated and stays ignored.)

After a `blade test --coverage` run the tests have written .gcda; the
runner then reports via gcovr (best-effort -- warns, never fails, if
gcovr is absent). Matching Blade's coverage.py: clang gcov data is read
with `llvm-cov gcov` (on macOS via `xcrun`, since Apple's `c++` is clang
but its data needs the matching llvm-cov), and coverage_config.exclude
globstar patterns become gcovr -e regexes. macOS/llvm-cov emits absurd
"suspicious" hit counts (gcc bug 68080), so the suspicious-hits threshold
is raised to keep the report clean.

Verified on flare (macOS/clang): `test //flare/base:chrono_test
--coverage` builds into build_release_coverage, runs, and prints the
gcovr summary (TOTAL ... 12%). Unit tests cover the build-dir variants
and the glob->regex translation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chen3feng
chen3feng merged commit d379e97 into main Jul 3, 2026
1 check passed
@chen3feng
chen3feng deleted the feat/coverage branch July 3, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant