Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions cmd/wippy/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
terminalservice "github.com/wippyai/runtime/service/terminal"
securitysys "github.com/wippyai/runtime/system/security"
supervisorpkg "github.com/wippyai/runtime/system/supervisor"
lua "github.com/wippyai/go-lua"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
Expand Down Expand Up @@ -312,6 +313,9 @@
waitForShutdownSignal(sigChan, logger, nil)

exitCode := shutdown.Perform(ctx, loader, logger, silentLogs)
if lua.CoverageEnabled() {

Check failure on line 316 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

undefined: lua.CoverageEnabled

Check failure on line 316 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

undefined: lua.CoverageEnabled

Check failure on line 316 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test SQLite CDC (Linux, CGO, race)

undefined: lua.CoverageEnabled

Check failure on line 316 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: lua.CoverageEnabled

Check failure on line 316 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: lua.CoverageEnabled
dumpCoverage()
}
if exitCode != 0 {
_ = logger.Sync()
os.Exit(exitCode)
Expand All @@ -320,6 +324,33 @@
return nil
}

// dumpCoverage writes an LCOV tracefile when WIPPY_COVERAGE is set. It runs both
// on a clean exit (return nil) and before os.Exit on a failing run, so coverage
// is captured even when tests fail. Configured via env:
//
// WIPPY_COVERAGE_FILE output path (default: coverage.info)
// WIPPY_COVERAGE_FILTER substring the source name must contain (default: all)
func dumpCoverage() {
prefix := os.Getenv("WIPPY_COVERAGE_FILTER")
filter := func(src string) bool {
return prefix == "" || strings.Contains(src, prefix)
}
path := os.Getenv("WIPPY_COVERAGE_FILE")
if path == "" {
path = "coverage.info"
}
if err := lua.WriteCoverageLCOV(path, filter); err != nil {

Check failure on line 342 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

undefined: lua.WriteCoverageLCOV

Check failure on line 342 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

undefined: lua.WriteCoverageLCOV

Check failure on line 342 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test SQLite CDC (Linux, CGO, race)

undefined: lua.WriteCoverageLCOV

Check failure on line 342 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: lua.WriteCoverageLCOV

Check failure on line 342 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: lua.WriteCoverageLCOV
fmt.Fprintf(os.Stderr, "coverage: write failed: %v\n", err)
return
}
lf, lh := lua.CoverageSummary(filter)

Check failure on line 346 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

undefined: lua.CoverageSummary

Check failure on line 346 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

undefined: lua.CoverageSummary

Check failure on line 346 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Test SQLite CDC (Linux, CGO, race)

undefined: lua.CoverageSummary

Check failure on line 346 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: lua.CoverageSummary) (typecheck)

Check failure on line 346 in cmd/wippy/cmd/run.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: lua.CoverageSummary) (typecheck)
pct := 0.0
if lf > 0 {
pct = float64(lh) / float64(lf) * 100
}
fmt.Fprintf(os.Stderr, "coverage: %d/%d lines (%.1f%%) filter=%q -> %s\n", lh, lf, pct, prefix, path)
}

// loadRuntimeConfig resolves the effective runtime configuration for run-like
// commands by merging:
// 1) config file/defaults,
Expand Down
Loading