Skip to content

fix(ci): measure coverage over all test targets, not just --lib - #7

Draft
h4x0r wants to merge 1 commit into
mainfrom
fix/coverage-all-test-targets
Draft

fix(ci): measure coverage over all test targets, not just --lib#7
h4x0r wants to merge 1 commit into
mainfrom
fix/coverage-all-test-targets

Conversation

@h4x0r

@h4x0r h4x0r commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What changes

-cargo llvm-cov --workspace --lib --lcov --output-path lcov.info
+cargo llvm-cov --workspace --lcov --output-path lcov.info --ignore-filename-regex '(^|/)src/(main\.rs|bin/)'

Why

--lib builds only the lib target's own unit tests. Integration tests under
tests/ are separate crates producing separate binaries — --lib never builds
them, so nothing they cover is ever recorded.

The number therefore means something narrower than it reads: code reached
through the public seam shows as uncovered even when the suite exercises it
fully. bluetooth-forensic hit exactly this — 54 lines reported uncovered on
a library its integration tests cover to 100%
. Acting on that number means
writing duplicate unit tests for already-tested code, or deleting the
integration tests that made it green.

Dropping --lib pulls binary targets in at 0% (built by the test profile, never
executed), which would make a 100% gate unsatisfiable for reasons unrelated to
test quality. Binary shells are excluded instead — the same rule
blob-decoder/scripts/coverage-gate.py already carries, for the same reason:
the CLI is a Humble Object over the library, and the library is what the gate is
about.

Risk

None to the current result. This repo passes today under --lib, which is
the stronger claim — the library is fully covered by unit tests alone.
Coverage can only grow when more test binaries run, and binaries are excluded.
What the change prevents is the phantom debt appearing the first time someone
covers new code from an integration test.

Fleet context

62 of the 76 repos with a coverage step already measure all test targets. This
brings the remaining outliers in line; ADR-0008 is being amended to match.

`cargo llvm-cov --lib` builds only the lib target's own unit tests. Integration
tests under tests/ are separate crates producing separate binaries, so `--lib`
never builds them and nothing they cover is recorded.

That makes the number mean something narrower than it reads. Any code reached
through the public seam rather than from inside src/ shows as uncovered even
when the suite exercises it fully. bluetooth-forensic hit exactly this: 54
lines reported uncovered on a library its own integration tests cover to 100%,
a phantom debt that would have sent someone writing duplicate unit tests for
code already tested -- or deleting the integration tests that made it green.

Dropping `--lib` pulls binary targets into the report at 0% (built by the test
profile, never executed), which would make a 100% gate unsatisfiable for
reasons unrelated to test quality. Binary shells are excluded instead, matching
the rule blob-decoder's gate script already carries: the CLI is a Humble Object
over the library, and the library is what the gate is about.

This repo passes today under `--lib`, which is the stronger claim -- the
library is fully covered by unit tests alone -- so this changes nothing about
its current result. Coverage can only grow when more test binaries run. What it
prevents is the phantom debt appearing the first time someone covers new code
from an integration test.

62 of the fleet's 76 repos with a coverage step already measure all test
targets; this brings the remaining outliers in line.
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