Skip to content

Commit

Permalink
Merge pull request #248 from egr-ext/develop
Browse files Browse the repository at this point in the history
Fix issue #242 when objc test classes and files are not found
  • Loading branch information
zippy1978 authored Jan 24, 2020
2 parents d0f0edb + 7880bb7 commit c8e7a5e
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 c8e7a5e

Please sign in to comment.