From b59320c2d1a202eb385745186f8d4976a6c48998 Mon Sep 17 00:00:00 2001 From: Albert Hui Date: Mon, 3 Aug 2026 08:57:55 +0800 Subject: [PATCH] fix(ci): measure coverage over all test targets, not just --lib `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. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14b21b2..bd1bd40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: # a future change. Such lines cannot be exercised by any test and are # exempt. The gate fails on any OTHER zero-hit line. - name: Generate lcov - run: cargo llvm-cov --lib --lcov --output-path lcov.info + run: cargo llvm-cov --lcov --output-path lcov.info --ignore-filename-regex '(^|/)src/(main\.rs|bin/)' - name: Enforce line coverage (unreachable defensive arms must carry // cov:unreachable) shell: bash run: |