Repository navigation
refactor(cli): reuse environment snapshots in tests - #159669
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 11:11 AM ET / 15:11 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch replaces handwritten environment restoration in CLI tests with the existing snapshot helper and removes an unused private voice-call type re-export. Merge readiness✅ Ready for maintainer review Keep open: the central cleanup remains useful and distinct from current main, sponsorship is now recorded, and no actionable introduced defect was found. Priority: P3 Review scores
Verification
How this fits togetherCLI tests temporarily change process environment variables to exercise command behavior. The shared snapshot helper restores the captured values during cleanup so subsequent tests retain their original environment. flowchart TD
A[Original environment] --> B[Capture selected keys]
B --> C[Exercise CLI behavior]
C --> D[Restore captured values]
D --> E{Original value defined?}
E -->|Yes| F[Restore original string]
E -->|No| G[Delete environment key]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -1, Tests -93. Total -94 across 18 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Use the existing environment snapshot owner throughout these tests while preserving their isolation, assertions, and lifecycle ordering. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR consolidates test cleanup rather than reporting a product failure; the pinned diff preserves the exercised scenarios. Is this the best way to solve the issue? Yes: reusing the existing helper removes duplicate restoration logic without introducing a competing owner or changing cleanup semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 27d3746e3c80. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
* refactor(cli): reuse environment snapshots in tests * refactor(cli): refresh environment snapshot cleanup Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
CLI tests duplicate environment snapshot and restoration code across 17 files. This is maintainer-approved standalone test maintenance requested by @vincentkoc; the deliverable is reuse of the existing
captureEnvhelper while preserving each test’s isolation and coverage.User Impact
No user-visible behavior change, configuration change, migration, or new action.
Why This Change Was Made
The existing helper preserves the original capture moment, key order, undefined deletion, empty strings, and cleanup placement. Current main’s rewritten tests and removed obsolete cases stay intact; three originally changed files now match main.
Current validation also exposed an unused private
CallBrieftype re-export introduced by #165716. This PR removes that one redundant export; the local import and canonical schema/brief exports remain.Final scope: tests +67/−160 (93 fewer lines); production +0/−1; 228 total changed lines.
Evidence
6693bb9665ced2a4fea3e286f62acfd0116e2c72: all 400 cases across 17 changed test files passed, one worker per file, Linux x64 / Node 24.19.0. Those exact test postimages remain unchanged after the type-only export deletion.git diff --checkpassed. Lint reported zero warnings/errors. The one-line export repair resolves the inherited dead-export failure.Per-file measured cost
Each command was
node scripts/run-vitest.mjs src/cli/<file> --maxWorkers=1 --reporter=json --outputFile=<report>. Wall time includes wrapper/startup overhead. The ClawHub install candidate also includes the required 15m 11.3s native E2E build; its 951.743s wall time is not a performance comparison with the warm control (42.557s wall, 12.543s file).cli-utils.test.tscommand-startup-policy.test.tsdaemon-cli/restart-health-client.test.tsdirectory-cli.test.tsgateway-cli/task-supervisor.test.tsnode-cli/identity.test.tsplugins-cli.clawhub-install.e2e.test.tsplugins-cli.uninstall.test.tsplugins-cli.update.test.tsplugins-search-command.clawhub.e2e.test.tsprogram/error-output.test.tsprogram/help.test.tsprogram/parent-default-help.test.tsprogram/preaction.test.tsprogram/subcli-descriptors.test.tsroute.test.tsupdate-cli.finalizer.test.ts