Skip to content

Exit with non-zero status when command line verification fails - #563

Merged
CatarinaGamboa merged 1 commit into
mainfrom
worktree-issue-562
Nov 30, 2026
Merged

CatarinaGamboa merged 1 commit into
mainfrom
worktree-issue-562

Conversation

@CatarinaGamboa

Copy link
Copy Markdown
Collaborator

Fixes #562

What and why

CommandLineLauncher.main printed the diagnostics and returned, so the process always exited with 0. CI jobs, scripts and exec-maven-plugin could not tell a failed verification from a passing one.

  • main now delegates to a new run(String...), which returns the exit status: 1 when diagnostics contain an error (including a path that was not found), 0 otherwise (pass, --help, --version).
  • main calls System.exit only for a non-zero status, so a passing run under mvn exec:java still ends normally, without stopping Maven early.
  • launch(...) is unchanged, as the issue suggested, because the VS Code language server calls it and must not exit.

Tests

  • New TestCommandLineExitCode: error file → 1, correct file → 0, missing path → 1, and an error in an earlier run does not leak into a later passing run.
  • End to end with the reproducer from the issue through ./liquidjava: exit 1 for a = -1, exit 0 for a = 1.
  • Full mvn test: 771 tests, 4 failures. All 4 also fail on main at 6a349c1 without this change, so this PR doesn't cause them:
    • TestAliasExpansions.messageDeclaresEachAliasOnceAsWritten
    • TestDeclarationPositions.stateErrorPointsToEveryEntryStateWithWhatItMeans
    • TestOriginNotes.unrefinedParameterIsNamedWithItsMethod
    • TestStateHints.foundKeepsANamedStateSetByItsName

🤖 Generated with Claude Code

CommandLineLauncher.main always returned normally, so the process exited
with 0 even when verification reported errors, and scripts, CI jobs and
exec-maven-plugin could not detect a failed verification.

main now delegates to run(String...), which returns 1 when diagnostics
contain an error and 0 otherwise, and calls System.exit only for a
non-zero status. launch(...) is unchanged, so the language server that
calls it is not affected.

Fixes #562

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CatarinaGamboa
CatarinaGamboa merged commit 9974d9b into main Nov 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant