Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Backelite/sonar-swift in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
zippy1978 committed Jan 24, 2020
2 parents 244d60c + c8e7a5e commit e5a0401
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,24 @@ public InputFile getUnitTestResource(FileSystem fileSystem, String classname) {
* wasn't found in the root.
*/
String lastFileNameComponents = StringUtils.substringAfterLast(fileName, "/");
if(!StringUtils.isEmpty(lastFileNameComponents)) {
fp = fileSystem.predicates().and(
fileSystem.predicates().hasType(InputFile.Type.TEST),
fileSystem.predicates().matchesPathPattern("**/" + fileName.replace("_", "+"))
);

if(fileSystem.hasFiles(fp)){
/*
* Lazily get the first file, since we wouldn't be able to determine the correct one from just the
* test class name in the event that there are multiple matches.
*/
return fileSystem.inputFiles(fp).iterator().next();
}
if(StringUtils.isEmpty(lastFileNameComponents)) {
lastFileNameComponents = fileName;
}

fp = fileSystem.predicates().and(
fileSystem.predicates().hasType(InputFile.Type.TEST),
fileSystem.predicates().matchesPathPattern("**/" + fileName.replace("_", "+"))
);

if(fileSystem.hasFiles(fp)){
/*
* Lazily get the first file, since we wouldn't be able to determine the correct one from just the
* test class name in the event that there are multiple matches.
*/
return fileSystem.inputFiles(fp).iterator().next();
}

LOGGER.info("Unable to locate Objective-C test source file for classname {}. Make sure your test class name matches its filename.", classname);
return null;
}
Expand Down

0 comments on commit e5a0401

Please sign in to comment.