Skip to content

test(cli): cover entrypoint behavior and exit codes#69

Open
scorpevans wants to merge 6 commits intomainfrom
test/20260304-2148-odetovibe-cli-gaps
Open

test(cli): cover entrypoint behavior and exit codes#69
scorpevans wants to merge 6 commits intomainfrom
test/20260304-2148-odetovibe-cli-gaps

Conversation

@scorpevans
Copy link
Owner

Summary

  • Source change: main() is now exported and wraps parseYaml in a narrow try-catch so ENOENT and YAML parse errors are caught, printed, and exit 1 — without swallowing the process.exit calls for help/no-args (which must remain outside the catch boundary to keep exit codes correct when process.exit is intercepted in tests)
  • printUsage flag tests: --out, --overwrite, --no-overwrite flags are listed in usage output
  • --help / -h: exits 0, prints usage
  • Missing argument: exits 1, prints usage
  • File not found: exits 1, prints the ENOENT error message to stderr
  • Invalid YAML: exits 1, prints [rule] entryKey: message validation errors to stderr
  • Happy path: resolves normally, process.exit is never called (implicit exit 0), created/updated lines appear in stdout

Each scenario is a separate commit. Exit codes are verified explicitly in every main() test via a captured exitCodes array (the process.exit mock pushes the code and throws to stop execution).

Test plan

  • pnpm --filter odetovibe test — all 158 tests pass
  • Verify CI passes on push

🤖 Generated with Claude Code

Evans Akai Bekoe and others added 6 commits March 4, 2026 21:57
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Narrows the error boundary to parseYaml only so that process.exit calls
for help/no-args remain outside any try-catch, keeping exit codes correct
when process.exit is intercepted in tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@scorpevans
Copy link
Owner Author

Reviewed. Checked: (1) all 6 commits target distinct gaps; (2) source change is minimal — export + narrow try-catch around parseYaml only, leaving all other process.exit calls outside any catch boundary (critical for correct exit codes under test); (3) ExitError throw-and-capture pattern is correct — codes are pushed before the throw so they survive even when the error propagates; (4) fakeConfigIndex satisfies the ConfigIndex interface; (5) happy-path test asserts exitCodes is empty (implicit exit 0) rather than asserting no-throw, which is more precise; (6) validation error format ([rule] entryKey) matches the exact format in cli.ts; (7) no untracked files referenced.

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.

1 participant