Skip to content

Commit e5a0401

Browse files
committed
Merge branch 'develop' of https://github.com/Backelite/sonar-swift into develop
2 parents 244d60c + c8e7a5e commit e5a0401

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

objclang/src/main/java/com/backelite/sonarqube/objectivec/surefire/ObjectiveCTestFileFinder.java

+16-12
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,24 @@ public InputFile getUnitTestResource(FileSystem fileSystem, String classname) {
4545
* wasn't found in the root.
4646
*/
4747
String lastFileNameComponents = StringUtils.substringAfterLast(fileName, "/");
48-
if(!StringUtils.isEmpty(lastFileNameComponents)) {
49-
fp = fileSystem.predicates().and(
50-
fileSystem.predicates().hasType(InputFile.Type.TEST),
51-
fileSystem.predicates().matchesPathPattern("**/" + fileName.replace("_", "+"))
52-
);
5348

54-
if(fileSystem.hasFiles(fp)){
55-
/*
56-
* Lazily get the first file, since we wouldn't be able to determine the correct one from just the
57-
* test class name in the event that there are multiple matches.
58-
*/
59-
return fileSystem.inputFiles(fp).iterator().next();
60-
}
49+
if(StringUtils.isEmpty(lastFileNameComponents)) {
50+
lastFileNameComponents = fileName;
6151
}
52+
53+
fp = fileSystem.predicates().and(
54+
fileSystem.predicates().hasType(InputFile.Type.TEST),
55+
fileSystem.predicates().matchesPathPattern("**/" + fileName.replace("_", "+"))
56+
);
57+
58+
if(fileSystem.hasFiles(fp)){
59+
/*
60+
* Lazily get the first file, since we wouldn't be able to determine the correct one from just the
61+
* test class name in the event that there are multiple matches.
62+
*/
63+
return fileSystem.inputFiles(fp).iterator().next();
64+
}
65+
6266
LOGGER.info("Unable to locate Objective-C test source file for classname {}. Make sure your test class name matches its filename.", classname);
6367
return null;
6468
}

0 commit comments

Comments
 (0)