Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GRAILS-6462 - support test target patterns that contain the full name…
… of the class.

e.g. grails test-app SomeTests.testMethod
  • Loading branch information
ldaley committed Sep 27, 2010
1 parent b5318a7 commit 8a6aa18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Expand Up @@ -78,12 +78,7 @@ class GrailsTestTargetPattern {
}

boolean matchesClass(String className, String[] suffixes) {
if (suffixes) {
def suffixesAsPattern = suffixes.collect { Pattern.quote(it) }.join('|')
className = className.replaceAll("(${suffixesAsPattern})\$", "")
}
def classNameAsPath = className.replace('.', '/')
new AntPathMatcher().match(filePattern, classNameAsPath)
matchesClassWithExtension(className) || matchesClassWithoutExtension(className, suffixes)
}

boolean matchesMethod(String methodName) {
Expand All @@ -94,6 +89,19 @@ class GrailsTestTargetPattern {
this.methodName != null
}

protected boolean matchesClassWithExtension(String className) {
new AntPathMatcher().match(filePattern, className.replace('.', '/'))
}

protected boolean matchesClassWithoutExtension(String className, String[] suffixes) {
if (suffixes) {
def suffixesAsPattern = suffixes.collect { Pattern.quote(it) }.join('|')
className = className.replaceAll("(${suffixesAsPattern})\$", "")
}
def classNameAsPath = className.replace('.', '/')
new AntPathMatcher().match(filePattern, classNameAsPath)
}

protected boolean containsMethodName(pattern) {
pattern.contains('.') && Character.isLowerCase(pattern.charAt(pattern.lastIndexOf('.') + 1))
}
Expand Down
Expand Up @@ -167,7 +167,8 @@ abstract class GrailsTestTypeSupport implements GrailsTestType {
protected List<File> findSourceFiles(GrailsTestTargetPattern targetPattern) {
def sourceFiles = []
def resolveResources = buildBinding['resolveResources']
testSuffixes.each { suffix ->
def suffixes = testSuffixes + [""] // support the target pattern containing the suffix
suffixes.each { suffix ->
testExtensions.each { extension ->
def resources = resolveResources("file:${sourceDir.absolutePath}/${targetPattern.filePattern}${suffix}.${extension}".toString())
sourceFiles.addAll(resources*.file.findAll { it.exists() }.toList())
Expand Down

0 comments on commit 8a6aa18

Please sign in to comment.