From f68934874ae1b862a8021c0d43b31047b143ea74 Mon Sep 17 00:00:00 2001 From: Albert Hui Date: Mon, 3 Aug 2026 08:57:50 +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 263affa..8d8a014 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: - uses: taiki-e/install-action@cargo-llvm-cov - name: Gate on 100% line coverage (excluding // cov:unreachable) run: | - 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/)' # Walk the lcov: track the current source file (SF:) and fail on any # DA:,0 whose source line lacks a `// cov:unreachable` marker. fail=0; file=""