diff --git a/engine/runner/src/main/java/org/enso/runner/Main.java b/engine/runner/src/main/java/org/enso/runner/Main.java index 465fc570bf4..46cbcc39583 100644 --- a/engine/runner/src/main/java/org/enso/runner/Main.java +++ b/engine/runner/src/main/java/org/enso/runner/Main.java @@ -518,7 +518,7 @@ public class Main { } /** Prints the help message to the standard output. */ - private static void printHelp() { + void printHelp() { new HelpFormatter().printHelp(LanguageInfo.ID, CLI_OPTIONS); } @@ -1436,6 +1436,7 @@ public class Main { System.currentTimeMillis() - startParsing); return line; } catch (Exception e) { + println(e.getMessage()); printHelp(); throw exitFail(); } diff --git a/engine/runner/src/test/java/org/enso/runner/EngineMainTest.java b/engine/runner/src/test/java/org/enso/runner/EngineMainTest.java index 9d00c45d9c8..91d42c609f4 100644 --- a/engine/runner/src/test/java/org/enso/runner/EngineMainTest.java +++ b/engine/runner/src/test/java/org/enso/runner/EngineMainTest.java @@ -3,6 +3,7 @@ package org.enso.runner; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.ArrayList; @@ -17,6 +18,21 @@ public class EngineMainTest { private final List linesOut = new ArrayList<>(); + @Test + public void unknownCommandBecauseTwoAreConcatenated() throws Exception { + var m = new MainMock(); + try { + var file = tempDir.newFile("some.enso"); + var line = m.preprocessArguments("--repl --inspect", "--run", file.getAbsolutePath()); + m.mainEntry(line, Level.INFO, false); + } catch (ExitCode ex) { + assertEquals("Execution fails", 1, ex.exitCode); + assertEquals("One line printed", 1, linesOut.size()); + assertEquals("Unrecognized option: --repl --inspect", linesOut.get(0)); + assertTrue("Also help was printed", m.helpPrinted); + } + } + @Test public void cannotUseReplAndInspectAtOnce() throws Exception { try { @@ -76,6 +92,8 @@ public class EngineMainTest { } private final class MainMock extends Main { + boolean helpPrinted; + @Override RuntimeException doExit(int exitCode) { throw new ExitCode(exitCode); @@ -85,6 +103,11 @@ public class EngineMainTest { void println(String msg) { linesOut.add(msg); } + + @Override + void printHelp() { + helpPrinted = true; + } } private static final class ExitCode extends RuntimeException {