aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml6
-rw-r--r--src/main/java/org/sonarsource/scanner/cli/Cli.java3
-rw-r--r--src/test/java/org/sonarsource/scanner/cli/CliTest.java20
3 files changed, 25 insertions, 4 deletions
diff --git a/pom.xml b/pom.xml
index 74a5a12..a8a1147 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
<dependency>
<groupId>org.sonarsource.scanner.api</groupId>
<artifactId>sonar-scanner-api</artifactId>
- <version>2.8-build684</version>
+ <version>2.8-build700</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -164,8 +164,8 @@
<configuration>
<rules>
<requireFilesSize>
- <minsize>510000</minsize>
- <maxsize>530000</maxsize>
+ <minsize>550000</minsize>
+ <maxsize>560000</maxsize>
<files>
<file>${project.build.directory}/sonar-scanner-${project.version}.zip</file>
</files>
diff --git a/src/main/java/org/sonarsource/scanner/cli/Cli.java b/src/main/java/org/sonarsource/scanner/cli/Cli.java
index 9019c6a..784f6c1 100644
--- a/src/main/java/org/sonarsource/scanner/cli/Cli.java
+++ b/src/main/java/org/sonarsource/scanner/cli/Cli.java
@@ -62,6 +62,7 @@ class Cli {
} else if ("-h".equals(arg) || "--help".equals(arg)) {
printUsage();
+ exit.exit(Exit.SUCCESS);
} else if ("-v".equals(arg) || "--version".equals(arg)) {
displayVersionOnly = true;
@@ -120,6 +121,7 @@ class Cli {
private void printError(String message) {
logger.error(message);
printUsage();
+ exit.exit(Exit.ERROR);
}
private void printUsage() {
@@ -133,6 +135,5 @@ class Cli {
logger.info(" -v,--version Display version information");
logger.info(" -X,--debug Produce execution debug output");
logger.info(" -i,--interactive Run interactively");
- exit.exit(Exit.SUCCESS);
}
}
diff --git a/src/test/java/org/sonarsource/scanner/cli/CliTest.java b/src/test/java/org/sonarsource/scanner/cli/CliTest.java
index 6bac2d0..840f35b 100644
--- a/src/test/java/org/sonarsource/scanner/cli/CliTest.java
+++ b/src/test/java/org/sonarsource/scanner/cli/CliTest.java
@@ -23,6 +23,7 @@ import org.junit.Test;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
public class CliTest {
Exit exit = mock(Exit.class);
@@ -77,4 +78,23 @@ public class CliTest {
assertThat(cli.isDisplayStackTrace()).isFalse();
assertThat(cli.properties().get("sonar.verbose")).isNull();
}
+
+ @Test
+ public void should_show_usage() {
+ logs = mock(Logs.class);
+ cli = new Cli(exit, logs);
+ cli.parse(new String[] {"-h"});
+ verify(logs).info("usage: sonar-scanner [options]");
+ verify(exit).exit(Exit.SUCCESS);
+ }
+
+ @Test
+ public void should_show_usage_on_bad_syntax() {
+ logs = mock(Logs.class);
+ cli = new Cli(exit, logs);
+ cli.parse(new String[] {"-w"});
+ verify(logs).error("Unrecognized option: -w");
+ verify(logs).info("usage: sonar-scanner [options]");
+ verify(exit).exit(Exit.ERROR);
+ }
}