From: Duarte Meneses Date: Wed, 9 Sep 2015 14:50:36 +0000 (+0200) Subject: Fix display help and remove work dir log X-Git-Tag: 2.5-rc1~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b1a26dced4593825b27a2a57672a11eca5530aa9;p=sonar-scanner-cli.git Fix display help and remove work dir log --- diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java index a2b0bd3..dc39e96 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java @@ -63,7 +63,7 @@ class Dirs { } } p.setProperty(RunnerProperties.WORK_DIR, workDirPath.normalize().toString()); - logger.info("Work directory: " + workDirPath.normalize().toString()); + logger.debug("Work directory: " + workDirPath.normalize().toString()); } /** diff --git a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Cli.java b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Cli.java index 8a34607..d0a350e 100644 --- a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Cli.java +++ b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Cli.java @@ -28,12 +28,12 @@ class Cli { private boolean displayVersionOnly = false; private boolean displayStackTrace = false; private boolean interactive = false; - private Properties props = new Properties(); - private final Exit exit; - private Logs logger; + private final Properties props = new Properties(); + private final Shutdown shutdown; + private final Logs logger; - public Cli(Exit exit, Logs logger) { - this.exit = exit; + public Cli(Shutdown shutdown, Logs logger) { + this.shutdown = shutdown; this.logger = logger; } @@ -147,6 +147,6 @@ 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); + shutdown.exit(Exit.SUCCESS); } } diff --git a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Main.java b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Main.java index 0229cc9..71488b3 100644 --- a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Main.java +++ b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Main.java @@ -60,7 +60,7 @@ public class Main { Exit exit = new Exit(); Shutdown shutdown = new Shutdown(exit); Logs logs = new Logs(); - Cli cli = new Cli(exit, logs).parse(args); + Cli cli = new Cli(shutdown, logs).parse(args); cli.verify(); Main main = new Main(shutdown, cli, new Conf(cli, logs), new RunnerFactory(logs), logs); main.execute(); diff --git a/sonar-runner-cli/src/test/java/org/sonar/runner/cli/CliTest.java b/sonar-runner-cli/src/test/java/org/sonar/runner/cli/CliTest.java index d343561..b8f6901 100644 --- a/sonar-runner-cli/src/test/java/org/sonar/runner/cli/CliTest.java +++ b/sonar-runner-cli/src/test/java/org/sonar/runner/cli/CliTest.java @@ -30,9 +30,9 @@ import org.sonar.runner.cli.Exit; import static org.fest.assertions.Assertions.assertThat; public class CliTest { - Exit exit = mock(Exit.class); + Shutdown shutdown = mock(Shutdown.class); Logs logs = new Logs(); - Cli cli = new Cli(exit, logs); + Cli cli = new Cli(shutdown, logs); @Test public void should_parse_empty_arguments() { @@ -45,31 +45,31 @@ public class CliTest { @Test public void should_extract_properties() { - cli.parse(new String[]{"-D", "foo=bar", "--define", "hello=world", "-Dboolean"}); + cli.parse(new String[] {"-D", "foo=bar", "--define", "hello=world", "-Dboolean"}); assertThat(cli.properties().get("foo")).isEqualTo("bar"); assertThat(cli.properties().get("hello")).isEqualTo("world"); assertThat(cli.properties().get("boolean")).isEqualTo("true"); } - + @Test public void dont_allow_interactive_fork() { - cli.parse(new String[]{"-i", "-DsonarRunner.mode=fork"}); + cli.parse(new String[] {"-i", "-DsonarRunner.mode=fork"}); cli.verify(); - verify(exit).exit(Exit.SUCCESS); + verify(shutdown).exit(Exit.SUCCESS); } @Test public void should_parse_optional_task() { - cli.parse(new String[]{"-D", "foo=bar"}); + cli.parse(new String[] {"-D", "foo=bar"}); assertThat(cli.properties().get("sonar.task")).isNull(); - cli.parse(new String[]{"views", "-D", "foo=bar"}); + cli.parse(new String[] {"views", "-D", "foo=bar"}); assertThat(cli.properties().get("sonar.task")).isEqualTo("views"); } @Test public void should_enable_debug_mode() { - cli.parse(new String[]{"-X"}); + cli.parse(new String[] {"-X"}); assertThat(cli.isDebugMode()).isTrue(); assertThat(cli.isDisplayStackTrace()).isTrue(); assertThat(cli.properties().get("sonar.verbose")).isEqualTo("true"); @@ -77,7 +77,7 @@ public class CliTest { @Test public void should_enable_stacktrace_log() { - cli.parse(new String[]{"-e"}); + cli.parse(new String[] {"-e"}); assertThat(cli.isDebugMode()).isFalse(); assertThat(cli.isDisplayStackTrace()).isTrue(); assertThat(cli.properties().get("sonar.verbose")).isNull();