aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2016-09-12 17:13:21 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2016-09-13 13:27:18 +0200
commit516ba9b922f4dab9f72077ee5ebf6eebda6c0d3a (patch)
treea393440f15a5a956997fff8a8641a7a5ef647aa9 /src
parentec22be60678b5ff5138e5ba6d3bba2fe7a5a5fc1 (diff)
downloadsonar-scanner-cli-516ba9b922f4dab9f72077ee5ebf6eebda6c0d3a.tar.gz
sonar-scanner-cli-516ba9b922f4dab9f72077ee5ebf6eebda6c0d3a.zip
SQSCANNER-28 Support sonar.scanner.skip without connecting to server
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/sonarsource/scanner/cli/Main.java9
-rw-r--r--src/test/java/org/sonarsource/scanner/cli/MainTest.java18
2 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/org/sonarsource/scanner/cli/Main.java b/src/main/java/org/sonarsource/scanner/cli/Main.java
index 9833c85..4c26e90 100644
--- a/src/main/java/org/sonarsource/scanner/cli/Main.java
+++ b/src/main/java/org/sonarsource/scanner/cli/Main.java
@@ -22,6 +22,7 @@ package org.sonarsource.scanner.cli;
import java.io.IOException;
import java.util.Properties;
import org.sonarsource.scanner.api.EmbeddedScanner;
+import org.sonarsource.scanner.api.ScanProperties;
/**
* Arguments :
@@ -65,6 +66,7 @@ public class Main {
try {
Properties p = conf.properties();
+ checkSkip(p);
configureLogging(p);
init(p);
runner.start();
@@ -79,6 +81,13 @@ public class Main {
runner.stop();
exit.exit(Exit.SUCCESS);
}
+
+ private void checkSkip(Properties properties) {
+ if ("true".equalsIgnoreCase(properties.getProperty(ScanProperties.SKIP))) {
+ logger.info("SonarQube Scanner analysis skipped");
+ exit.exit(Exit.SUCCESS);
+ }
+ }
private void init(Properties p) throws IOException {
SystemInfo.print(logger);
diff --git a/src/test/java/org/sonarsource/scanner/cli/MainTest.java b/src/test/java/org/sonarsource/scanner/cli/MainTest.java
index 06adc9d..450d0a7 100644
--- a/src/test/java/org/sonarsource/scanner/cli/MainTest.java
+++ b/src/test/java/org/sonarsource/scanner/cli/MainTest.java
@@ -29,6 +29,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.sonarsource.scanner.api.EmbeddedScanner;
+import org.sonarsource.scanner.api.ScanProperties;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Matchers.any;
@@ -150,6 +151,23 @@ public class MainTest {
inOrder.verify(runnerFactory, times(1)).create(p);
inOrder.verify(exit, times(1)).exit(Exit.SUCCESS);
}
+
+ @Test
+ public void should_skip() throws IOException {
+ Properties p = new Properties();
+ p.setProperty(ScanProperties.SKIP, "true");
+ when(conf.properties()).thenReturn(p);
+
+ Main main = new Main(exit, cli, conf, runnerFactory, logs);
+ main.execute();
+
+ verify(logs).info("SonarQube Scanner analysis skipped");
+ InOrder inOrder = Mockito.inOrder(exit, runnerFactory);
+
+ inOrder.verify(exit, times(1)).exit(Exit.SUCCESS);
+ inOrder.verify(runnerFactory, times(1)).create(p);
+ inOrder.verify(exit, times(1)).exit(Exit.SUCCESS);
+ }
@Test
public void shouldLogServerVersion() throws IOException {