From d4056962cea2659844ac18ab84e861e4481f038e Mon Sep 17 00:00:00 2001 From: serge-rider Date: Mon, 19 Oct 2026 07:14:27 +0200 Subject: [PATCH 1/2] dbeaver/pro#11169 Cover CLI command startup paths --- .../src/org/dbvr/test/HelpArgTest.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/test/org.dbvr.test.platform/src/org/dbvr/test/HelpArgTest.java b/test/org.dbvr.test.platform/src/org/dbvr/test/HelpArgTest.java index c0834e4..33be611 100644 --- a/test/org.dbvr.test.platform/src/org/dbvr/test/HelpArgTest.java +++ b/test/org.dbvr.test.platform/src/org/dbvr/test/HelpArgTest.java @@ -16,9 +16,12 @@ */ package org.dbvr.test; +import org.dbvr.cli.app.CLITopLevelCommand; import org.dbvr.cli.app.ce.command.TestCommand; import org.jkiss.code.NotNull; +import org.jkiss.dbeaver.model.cli.CLIConstants; import org.jkiss.dbeaver.model.cli.CLIProcessResult; +import org.jkiss.dbeaver.model.cli.command.AbstractTopLevelCommand; import org.jkiss.utils.CommonUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -45,6 +48,67 @@ public void testEmptyArgs() throws Exception { Assertions.assertEquals(resultWithArg.getOutput(), resultNoArg.getOutput()); } + @Test + public void testRootHelpIncludesOtherCommands() throws Exception { + CLIProcessResult result = DBVRTestSuite.getApplication().executeCommandLine(new String[] {"--help"}); + String help = result.getOutput().getFirst(); + + Assertions.assertTrue(help.contains("driver")); + Assertions.assertTrue(help.contains("project")); + Assertions.assertTrue(help.contains("sql")); + } + + @Test + public void testRootHelpAliasesMatch() throws Exception { + var app = DBVRTestSuite.getApplication(); + var help = app.executeCommandLine(new String[] {AbstractTopLevelCommand.HELP_OPTION}).getOutput(); + + Assertions.assertEquals(help, + app.executeCommandLine(new String[] {AbstractTopLevelCommand.SHORT_HELP_OPTION}).getOutput()); + Assertions.assertEquals(help, + app.executeCommandLine(new String[] {AbstractTopLevelCommand.LEGACY_HELP_OPTION}).getOutput()); + } + + @Test + public void testRootVersionOptionsMatchFullParser() throws Exception { + var app = DBVRTestSuite.getApplication(); + for (String option : new String[] {"-v", "-V", "--version"}) { + CLIProcessResult rootOnly = app.executeCommandLine(new String[] {option}); + CLIProcessResult fullParser = app.executeCommandLine( + new String[] {CLITopLevelCommand.OPTION_STATELESS, option}); + + Assertions.assertEquals(fullParser.getOutput(), rootOnly.getOutput()); + Assertions.assertEquals(fullParser.getExitCode(), rootOnly.getExitCode()); + Assertions.assertEquals(CLIProcessResult.PostAction.SHUTDOWN, rootOnly.getPostAction()); + } + } + + @Test + public void testSelectedCommandHelpMatchesOptionFirstInvocation() throws Exception { + var app = DBVRTestSuite.getApplication(); + CLIProcessResult selected = app.executeCommandLine(new String[] {"driver", "--help"}); + CLIProcessResult optionFirst = app.executeCommandLine( + new String[] {CLITopLevelCommand.OPTION_STATELESS, "driver", "--help"}); + + Assertions.assertEquals(optionFirst.getOutput(), selected.getOutput()); + Assertions.assertEquals(optionFirst.getExitCode(), selected.getExitCode()); + } + + @Test + public void testUnknownCommandsStillReportTheirLocation() throws Exception { + var app = DBVRTestSuite.getApplication(); + CLIProcessResult unknownRoot = app.executeCommandLine(new String[] {"unknown-command"}); + CLIProcessResult unknownOption = app.executeCommandLine(new String[] {"--unknown-option"}); + CLIProcessResult unknownSubcommand = app.executeCommandLine(new String[] {"driver", "unknown-subcommand"}); + + Assertions.assertEquals(CLIConstants.EXIT_CODE_ERROR, unknownRoot.getExitCode()); + Assertions.assertTrue(unknownRoot.getOutput().getFirst().contains("after 'dbvr'")); + Assertions.assertEquals(CLIConstants.EXIT_CODE_ERROR, unknownOption.getExitCode()); + Assertions.assertTrue(unknownOption.getOutput().getFirst().contains("after 'dbvr'")); + Assertions.assertEquals(CLIConstants.EXIT_CODE_ERROR, unknownSubcommand.getExitCode()); + Assertions.assertTrue(unknownSubcommand.getOutput().getFirst().contains("after 'driver'")); + } + @Test public void testSqlHelpContainsDefaultSchema() throws Exception { CLIProcessResult result = DBVRTestSuite.getApplication().executeCommandLine(new String[] {"sql", "--help"}); From bc7aec820daa5be6fce12a27b30c628fa3ec9952 Mon Sep 17 00:00:00 2001 From: serge-rider Date: Mon, 19 Oct 2026 08:16:19 +0200 Subject: [PATCH 2/2] dbeaver/pro#11169 Verify completion lists contributed commands --- .../src/org/dbvr/test/HelpArgTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/org.dbvr.test.platform/src/org/dbvr/test/HelpArgTest.java b/test/org.dbvr.test.platform/src/org/dbvr/test/HelpArgTest.java index 33be611..cec8df5 100644 --- a/test/org.dbvr.test.platform/src/org/dbvr/test/HelpArgTest.java +++ b/test/org.dbvr.test.platform/src/org/dbvr/test/HelpArgTest.java @@ -94,6 +94,18 @@ public void testSelectedCommandHelpMatchesOptionFirstInvocation() throws Excepti Assertions.assertEquals(optionFirst.getExitCode(), selected.getExitCode()); } + @Test + public void testCompletionContainsContributedCommands() throws Exception { + CLIProcessResult result = DBVRTestSuite.getApplication().executeCommandLine(new String[] {"completion"}); + String script = result.getOutput().getFirst(); + + Assertions.assertEquals(CLIProcessResult.PostAction.SHUTDOWN, result.getPostAction()); + Assertions.assertTrue(script.contains("driver")); + Assertions.assertTrue(script.contains("project")); + Assertions.assertTrue(script.contains("sql")); + Assertions.assertTrue(script.contains(TestCommand.TEST_COMMAND_NAME)); + } + @Test public void testUnknownCommandsStillReportTheirLocation() throws Exception { var app = DBVRTestSuite.getApplication();