Skip to content

Commit

Permalink
fix CxxProjectBuilder
Browse files Browse the repository at this point in the history
(cherry picked from commit 72e039f)

Conflicts:
	sonar-cxx-plugin/src/test/java/org/sonar/plugins/cxx/CxxPluginTest.java
  • Loading branch information
guwirth authored and Jorge Costa committed Jan 10, 2016
1 parent 634d6e5 commit 81b275f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ private static List<PropertyDefinition> testingAndCoverageProperties() {
@Override
public List getExtensions() {
List<Object> l = new ArrayList<>();
l.add(CxxProjectBuilder.class);
l.add(CxxLanguage.class);
l.add(CxxMetrics.class);
l.add(CxxSquidSensor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ public class CxxProjectBuilder extends ProjectBuilder {

public CxxProjectBuilder() {
super();
LOG.debug("using CxxProjectBuilder");
}

/**
* additional support of variables in configuration files
*
* - format for placeholder is ${xxx}
* - supported are environment variables, Java system properties and SonarQube properties
* - backslashes in values from environment variables and Java
* system properties are replaced with slashes to support Windows paths
*/
@Override
public void build(Context context) {
Expand All @@ -57,14 +56,12 @@ public void build(Context context) {
for (Map.Entry<String, String> entry : envMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
value = value.replace("\\", "/");
vars.put(key, value);
}

Properties props = System.getProperties();
for (String key : props.stringPropertyNames()) {
String value = props.getProperty(key);
value = value.replace("\\", "/");
vars.put(key, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public class CxxPluginTest {
@Test
public void testGetExtensions() throws Exception {
CxxPlugin plugin = new CxxPlugin();
assertEquals(63, plugin.getExtensions().size());
assertEquals(65, plugin.getExtensions().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class CxxProjectBuilderTest {
public void setUp() {
// setting values to expand
System.setProperty("cxx.test.key1", "value");
System.setProperty("cxx.test.path1", "C:\\test\\reports\\a.xml");
}

@Test
Expand Down Expand Up @@ -68,12 +67,4 @@ public void replaceStringList2() {
assertThat(value).isEqualTo("value, ${undefined}, xxx");
}

@Test
public void replaceStringBackslash() {
projectDefinition.setProperty("key4", "${cxx.test.path1}");
context = new ProjectBuilderContext(new ProjectReactor(projectDefinition));
projectBuilder.build(context);
String value = context.projectReactor().getRoot().getProperties().getProperty("key4");
assertThat(value).isEqualTo("C:/test/reports/a.xml");
}
}

0 comments on commit 81b275f

Please sign in to comment.