Skip to content

Commit

Permalink
Detection of test files with '+' in name
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilles Grousset committed Jan 22, 2015
1 parent 2f9b6ad commit 0d261ed
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package org.sonar.plugins.objectivec.tests;

import com.sun.swing.internal.plaf.metal.resources.metal_sv;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.batch.SensorContext;
Expand Down Expand Up @@ -142,13 +143,23 @@ private void saveTestsDetails(SensorContext context, TestSuiteReport fileReport)

private void saveClassMeasure(SensorContext context, TestSuiteReport fileReport, Metric metric, double value) {
if ( !Double.isNaN(value)) {
context.saveMeasure(getUnitTestResource(fileReport.getClassKey()), metric, value);

String basename = fileReport.getClassKey().replace('.', '/');

// .m file
context.saveMeasure(getUnitTestResource(basename + ".m"), metric, value);

// Try .m file with + in name
try {
context.saveMeasure(getUnitTestResource(basename.replace('_', '+') + ".m"), metric, value);
} catch (Exception e) {
// Nothing : File was probably already registered successfully
}
}
}

public Resource getUnitTestResource(String classKey) {
public Resource getUnitTestResource(String filename) {

String filename = classKey.replace('.', '/') + ".m";
org.sonar.api.resources.File sonarFile = new org.sonar.api.resources.File(filename);
sonarFile.setQualifier(Qualifiers.UNIT_TEST_FILE);
return sonarFile;
Expand Down

0 comments on commit 0d261ed

Please sign in to comment.