feat(coverage): write LCOV after 'wippy test' when WIPPY_COVERAGE is set - #553
Open
xepozz wants to merge 1 commit into
Open
feat(coverage): write LCOV after 'wippy test' when WIPPY_COVERAGE is set#553xepozz wants to merge 1 commit into
xepozz wants to merge 1 commit into
Conversation
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.
Contributor
There was a problem hiding this comment.
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-luaand guards coverage export behindlua.CoverageEnabled(). - Adds a
dumpCoveragehelper to write an LCOV file and print a summary, configured viaWIPPY_COVERAGE_FILEandWIPPY_COVERAGE_FILTER. - Invokes coverage dumping after
shutdown.Perform(...)and before any non-zeroos.Exit(exitCode).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
292
to
+295
| exitCode := shutdown.Perform(ctx, loader, logger, silentLogs) | ||
| if lua.CoverageEnabled() { | ||
| dumpCoverage() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Writes an LCOV coverage tracefile after
wippy testwhenWIPPY_COVERAGEisset, so the native test suite can be run under line coverage.
How
After the test entrypoint finishes in
runWithUseCase(right aftershutdown.Perform), it calls the go-lua coverage collector:dumpCoveragewrites the LCOV file and prints an aggregate summary. It runs onboth the clean-exit path and before
os.Exit(exitCode)on a failing run, socoverage 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 (defaultcoverage.info).WIPPY_COVERAGE_FILTER— substring the chunk/source name must contain(default: all sources).
Usage
The resulting
coverage.infois consumed as-is bygenhtml, Codecov, and editorcoverage plugins.
Performance
No-op when
WIPPY_COVERAGEis unset:lua.CoverageEnabled()short-circuits, sonormal runs are unaffected.
Scope of changes
One file —
cmd/wippy/cmd/run.go: theluaimport, thedumpCoveragehelper,and the guarded call after
shutdown.Perform.