]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
SQSCANNER-39 Don't filter properties with blank value
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 12 Apr 2017 13:35:13 +0000 (15:35 +0200)
committerJulien HENRY <henryju@yahoo.fr>
Wed, 12 Apr 2017 18:57:37 +0000 (20:57 +0200)
it/pom.xml
it/src/test/java/com/sonar/runner/it/JavaTest.java
pom.xml
src/main/java/org/sonarsource/scanner/cli/PropertyResolver.java
src/test/java/org/sonarsource/scanner/cli/PropertyResolverTest.java

index ea1dfac2883ebb18e3c6ec0d2ba4ad5c7763140e..4e3e09002666910e082cd612a059080d1cab9d9e 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.sonarsource.parent</groupId>
     <artifactId>parent</artifactId>
-    <version>37</version>
+    <version>40</version>
     <relativePath />
   </parent>
 
index 35191599072d32ecf27e947e55701310729215a4..2e7f95c6c5d5a9030f1c18524362c94eddbdd4c9 100644 (file)
@@ -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"));
diff --git a/pom.xml b/pom.xml
index b25c8a007b05ec7ab5b356db7097361d988bb9a9..abaa87f5ace7ce9c4aae533925f8626bff1c1f49 100644 (file)
--- a/pom.xml
+++ b/pom.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>
index d1fe2c85b48f0af9ddcf21eb05951a5c9aac2a5d..d92f7fedc446d4e867206315d583f0c73e630944 100644 (file)
@@ -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;
     }
 
index cece2a02a2216c1e2efcae4197e7b914ee1d63b5..eecca988315a354f450da39d3f6e761c1ee317ff 100644 (file)
  */
 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("");
+  }
 }