diff options
-rw-r--r-- | it/pom.xml | 2 | ||||
-rw-r--r-- | it/src/test/java/com/sonar/runner/it/JavaTest.java | 23 | ||||
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | src/main/java/org/sonarsource/scanner/cli/PropertyResolver.java | 1 | ||||
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/PropertyResolverTest.java | 19 |
5 files changed, 40 insertions, 7 deletions
@@ -6,7 +6,7 @@ <parent> <groupId>org.sonarsource.parent</groupId> <artifactId>parent</artifactId> - <version>37</version> + <version>40</version> <relativePath /> </parent> diff --git a/it/src/test/java/com/sonar/runner/it/JavaTest.java b/it/src/test/java/com/sonar/runner/it/JavaTest.java index 3519159..2e7f95c 100644 --- a/it/src/test/java/com/sonar/runner/it/JavaTest.java +++ b/it/src/test/java/com/sonar/runner/it/JavaTest.java @@ -60,8 +60,7 @@ public class JavaTest extends ScannerTestCase { orchestrator.getServer().associateProjectToQualityProfile("java:sample", "java", "sonar-way"); SonarScanner build = newScanner(new File("projects/java-sample")) - .setProperty("sonar.verbose", "true") - .addArguments("-e"); + .setProperty("sonar.verbose", "true"); // SONARPLUGINS-3061 // Add a trailing slash build.setProperty("sonar.host.url", orchestrator.getServer().getUrl() + "/"); @@ -86,6 +85,26 @@ public class JavaTest extends ScannerTestCase { assertThat(parseInt(fileMeasures.get("violations").getValue())).isGreaterThan(0); } + /** + * Only tests, no sources + */ + @Test + public void scan_java_tests() { + orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml")); + orchestrator.getServer().provisionProject("java:sampletest", "Java Sample"); + orchestrator.getServer().associateProjectToQualityProfile("java:sampletest", "java", "sonar-way"); + + SonarScanner build = newScanner(new File("projects/java-sample")) + .setProperty("sonar.projectKey", "java:sampletest") + .setProperty("sonar.tests", "src") + .setProperty("sonar.sources", ""); + orchestrator.executeBuild(build); + + Component file = getComponent("java:sampletest:src/basic/Hello.java"); + assertThat(file.getName()).isEqualTo("Hello.java"); + assertThat(file.getQualifier()).isEqualTo("UTS"); + } + @Test public void scan_java_sources_and_bytecode() { orchestrator.getServer().restoreProfile(ResourceLocation.create("/requires-bytecode-profile.xml")); @@ -8,7 +8,7 @@ <groupId>org.sonarsource.scanner.cli</groupId> <artifactId>sonar-scanner-cli</artifactId> - <version>3.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>SonarQube Scanner</name> <url>http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner</url> diff --git a/src/main/java/org/sonarsource/scanner/cli/PropertyResolver.java b/src/main/java/org/sonarsource/scanner/cli/PropertyResolver.java index d1fe2c8..d92f7fe 100644 --- a/src/main/java/org/sonarsource/scanner/cli/PropertyResolver.java +++ b/src/main/java/org/sonarsource/scanner/cli/PropertyResolver.java @@ -67,6 +67,7 @@ public class PropertyResolver { private String resolveProperty(String propKey) { String propValue = getValue(propKey); if (propValue.isEmpty()) { + resolved.setProperty(propKey, propValue); return propValue; } diff --git a/src/test/java/org/sonarsource/scanner/cli/PropertyResolverTest.java b/src/test/java/org/sonarsource/scanner/cli/PropertyResolverTest.java index cece2a0..eecca98 100644 --- a/src/test/java/org/sonarsource/scanner/cli/PropertyResolverTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/PropertyResolverTest.java @@ -19,16 +19,15 @@ */ package org.sonarsource.scanner.cli; -import static org.assertj.core.api.Assertions.assertThat; - import java.util.HashMap; import java.util.Map; import java.util.Properties; - import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import static org.assertj.core.api.Assertions.assertThat; + public class PropertyResolverTest { @Rule public ExpectedException exception = ExpectedException.none(); @@ -120,4 +119,18 @@ public class PropertyResolverTest { PropertyResolver resolver = new PropertyResolver(map, env); resolver.resolve(); } + + @Test + public void preserve_empty() { + Properties map = new Properties(); + Map<String, String> env = new HashMap<>(); + + map.put("A", ""); + map.put("B", "${A}"); + + PropertyResolver resolver = new PropertyResolver(map, env); + Properties resolved = resolver.resolve(); + assertThat(resolved.get("A")).isEqualTo(""); + assertThat(resolved.get("B")).isEqualTo(""); + } } |