Browse Source

SQSCANNER-39 Don't filter properties with blank value

tags/3.0.1.733
Julien HENRY 7 years ago
parent
commit
3f8feb0905

+ 1
- 1
it/pom.xml View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.sonarsource.parent</groupId>
<artifactId>parent</artifactId>
<version>37</version>
<version>40</version>
<relativePath />
</parent>


+ 21
- 2
it/src/test/java/com/sonar/runner/it/JavaTest.java View 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"));

+ 1
- 1
pom.xml View File

@@ -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>

+ 1
- 0
src/main/java/org/sonarsource/scanner/cli/PropertyResolver.java View 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;
}


+ 16
- 3
src/test/java/org/sonarsource/scanner/cli/PropertyResolverTest.java View File

@@ -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("");
}
}

Loading…
Cancel
Save