Skip to content

feat(coverage): write LCOV after 'wippy test' when WIPPY_COVERAGE is set - #553

Open
xepozz wants to merge 1 commit into
wippyai:mainfrom
xepozz:feature/coverage-dump
Open

feat(coverage): write LCOV after 'wippy test' when WIPPY_COVERAGE is set#553
xepozz wants to merge 1 commit into
wippyai:mainfrom
xepozz:feature/coverage-dump

Conversation

@xepozz

@xepozz xepozz commented Aug 4, 2026

Copy link
Copy Markdown

Depends on wippyai/go-lua#35
(the line-coverage collector, which itself stacks on go-lua#34). This PR calls
that collector's WriteCoverageLCOV/CoverageSummary, so it needs a go-lua
version that includes #35 to build. Please land the go-lua PRs first.

What

Writes an LCOV coverage tracefile after wippy test when WIPPY_COVERAGE is
set, so the native test suite can be run under line coverage.

How

After the test entrypoint finishes in runWithUseCase (right after
shutdown.Perform), it calls the go-lua coverage collector:

if lua.CoverageEnabled() {
    dumpCoverage()
}

dumpCoverage writes the LCOV file and prints an aggregate summary. It runs on
both the clean-exit path and before os.Exit(exitCode) on a failing run, so
coverage is captured even when tests fail (failing tests still execute code).

Configured via env:

  • WIPPY_COVERAGE — enable (read by go-lua at init).
  • WIPPY_COVERAGE_FILE — output path (default coverage.info).
  • WIPPY_COVERAGE_FILTER — substring the chunk/source name must contain
    (default: all sources).

Usage

WIPPY_COVERAGE=1 WIPPY_COVERAGE_FILE=coverage.info WIPPY_COVERAGE_FILTER=@app \
  wippy test --host <cli_host>
# → writes coverage.info (LCOV) and prints: coverage: <hit>/<found> lines (<pct>%)

The resulting coverage.info is consumed as-is by genhtml, Codecov, and editor
coverage plugins.

Performance

No-op when WIPPY_COVERAGE is unset: lua.CoverageEnabled() short-circuits, so
normal runs are unaffected.

Scope of changes

One file — cmd/wippy/cmd/run.go: the lua import, the dumpCoverage helper,
and the guarded call after shutdown.Perform.

Calls the go-lua coverage collector's WriteCoverageLCOV/CoverageSummary right
after shutdown.Perform in runWithUseCase — covering both the clean-exit and the
os.Exit(exitCode!=0) paths, so coverage is captured even when tests fail.

Configured via env: WIPPY_COVERAGE (enable, read by go-lua at init),
WIPPY_COVERAGE_FILE (output, default coverage.info), WIPPY_COVERAGE_FILTER
(source-name substring, e.g. 'app.').

Requires the go-lua coverage collector (CoverageEnabled/WriteCoverageLCOV/
CoverageSummary) — not in upstream go-lua v1.5.16. Build with:
  go mod edit -replace github.com/wippyai/go-lua=/path/to/go-lua@feature/coverage-collector
No-op (single bool check) when WIPPY_COVERAGE is unset.
Copilot AI lite review requested due to automatic review settings August 4, 2026 09:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional Lua line-coverage export for the wippy CLI by writing an LCOV tracefile after the command run completes when coverage collection is enabled (via WIPPY_COVERAGE as interpreted by go-lua). This enables running the native test suite under line coverage and emitting a summary + LCOV output for downstream tooling.

Changes:

  • Imports github.com/wippyai/go-lua and guards coverage export behind lua.CoverageEnabled().
  • Adds a dumpCoverage helper to write an LCOV file and print a summary, configured via WIPPY_COVERAGE_FILE and WIPPY_COVERAGE_FILTER.
  • Invokes coverage dumping after shutdown.Perform(...) and before any non-zero os.Exit(exitCode).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/wippy/cmd/run.go
Comment on lines 292 to +295
exitCode := shutdown.Perform(ctx, loader, logger, silentLogs)
if lua.CoverageEnabled() {
dumpCoverage()
}
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.

2 participants