Skip to content

Replace ASCII-table coverage parsing with lcov #44

@rubydusa

Description

@rubydusa

Problem

`scripts/coverage/extract-summary.sh` parses `forge coverage`'s box-drawing-character output:

  • `awk '/^╭/,/^╰/' coverage-raw.txt > coverage-table.txt`
  • `grep '^|' ... | grep "$COVERAGE_SOURCE_FILTER"`
  • `grep -oP '(\K[0-9]+/[0-9]+'`

The output format has changed across Foundry versions and is not a stable contract. Every Foundry update is a latent breakage risk for every consumer repo.

Proposal

Switch to `forge coverage --report lcov`. lcov is a stable, well-documented format with mature tooling. We can compute totals from `LH/LF`, `BRH/BRF`, `FNH/FNF` records with a small awk script and skip the box-drawing parsing entirely.

Trade-off: `forge coverage --report lcov` does not separate "statements" from "lines" the way the table does — lcov only tracks lines, branches, and functions. We'd drop the "statements" metric (or report it equal to lines for backwards compatibility).

Acceptance

  • `extract-summary.sh` reads lcov, not ASCII.
  • `coverage-comment.md` is functionally equivalent.
  • `tests/fixtures/coverage-raw.txt` replaced with an lcov fixture.
  • Tests still pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions