Skip to content

Commit 2be0222

Browse files
author
Gilles Grousset
committed
Fixed test count
1 parent c6636d1 commit 2be0222

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/surefire/SurefireSensor.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import java.io.File;
2929
import java.io.IOException;
30+
import java.nio.file.DirectoryStream;
3031
import java.nio.file.Files;
3132
import java.nio.file.Path;
3233
import java.nio.file.Paths;
@@ -52,8 +53,7 @@ protected String reportPath() {
5253
public void describe(SensorDescriptor descriptor) {
5354
descriptor
5455
.name("Surefire")
55-
.onlyOnLanguages("swift","objc")
56-
.onlyOnFileType(InputFile.Type.MAIN);
56+
.onlyOnLanguages("swift","objc");
5757
}
5858

5959
@Override
@@ -66,14 +66,16 @@ public void execute(SensorContext context) {
6666
LOGGER.warn("JUnit report directory not found at {}", reportsDir);
6767
return;
6868
}
69-
try {
70-
for (Path p : Files.newDirectoryStream(Paths.get(reportsDir.toURI()), name -> (name.startsWith("TEST") && name.endsWith(".xml")) || name.endsWith(".junit"))) {
69+
70+
try (DirectoryStream<Path> stream = Files.newDirectoryStream(reportsDir.toPath(), "{TEST}*.{xml}")) {
71+
for (Path p: stream) {
7172
LOGGER.info("Processing Surefire report {}", p.getFileName());
7273
surefireParser.parseReport(p.toFile());
7374
}
74-
} catch (IOException ex){
75-
LOGGER.error( "Error while finding test files.", ex);
75+
} catch (IOException e) {
76+
LOGGER.error( "Error while finding test files.", e);
7677
}
78+
7779
surefireParser.save();
7880
}
7981
}

0 commit comments

Comments
 (0)