Repository navigation
[test] Add tests for cmd.postRun - #16614
Conversation
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified, with deterministic coverage for successful, repeated, uninitialized, and failed logger-cleanup scenarios including warning behavior.
No open issues 🎉
What changed in this PR
Adds deterministic lifecycle tests for internal/cmd.postRun, covering successful logger cleanup, repeated invocation, and cleanup-error warning behavior.
Changes:
- Added an injectable logger-cleanup seam for deterministic failure testing.
- Added coverage for uninitialized, successful, repeated, and failed cleanup scenarios.
- Verified warning logging without panics on cleanup failure.
| File | Description |
|---|---|
| internal/cmd/root.go | Routes postRun logger cleanup through an injectable function while preserving normal production behavior. |
| internal/cmd/root_lifecycle_test.go | Adds tests covering successful, repeated, uninitialized, and failed logger cleanup scenarios. |
Review effort: Lite (dynamic)
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write of any kind succeeded or leaked through on this runtime; no artifacts were created.
|
Function Analyzed
internal/cmdpostRunWhy This Function?
The repository-wide coverage report identified
postRunas the lowest-coverage non-trivial function. Its logger cleanup warning path was untested, despite being the CLI's final cleanup hook.Tests Added
A small package-level cleanup seam keeps the production behavior unchanged while allowing the error branch to be exercised deterministically.
Coverage Report
Test Execution
go test -v -coverprofile=/tmp/gh-aw/agent/cmd-coverage.out ./internal/cmd -run TestPostRun— passedgo test -coverprofile=coverage.out ./...— passed;postRun100.0%, total 97.5%make agent-finished— Go build, vet, and all Go unit/integration tests passed; golangci-lint was unavailable and skipped by the MakefileserdepackageWarning
Firewall blocked 4 domains
The following domains were blocked by the firewall during workflow execution:
example.comnonexistent.localslow.example.comthishostdoesnotexist12345.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.