Auto-add pattern for running inner tests in Gradle (KT-24961)
Since Gradle 4.7 there's a more strict pattern check. Simple include trick doesn't work anymore. Probably modification of TestSelectionMatcher.java in https://github.com/gradle/gradle/commit/c2067eaa129af4c9c29ad08da39d1c853eec4c59#diff-e92afe807d7ea74cc9ab0dcef30efc93 is responsible for the new behaviour. #KT-24961 Fixed
This commit is contained in:
@@ -33,11 +33,14 @@ fun Project.projectTest(taskName: String = "test", body: Test.() -> Unit = {}):
|
||||
val patterns = filter.includePatterns + ((filter as? DefaultTestFilter)?.commandLineIncludePatterns ?: emptySet())
|
||||
if (patterns.isEmpty() || patterns.any { '*' in it }) return@doFirst
|
||||
patterns.forEach { pattern ->
|
||||
var isClassPattern = false
|
||||
val maybeMethodName = pattern.substringAfterLast('.')
|
||||
val maybeClassFqName = if (maybeMethodName.isFirstChar(::isLowerCase))
|
||||
val maybeClassFqName = if (maybeMethodName.isFirstChar(::isLowerCase)) {
|
||||
pattern.substringBeforeLast('.')
|
||||
else
|
||||
} else {
|
||||
isClassPattern = true
|
||||
pattern
|
||||
}
|
||||
|
||||
if (!maybeClassFqName.substringAfterLast('.').isFirstChar(::isUpperCase)) {
|
||||
return@forEach
|
||||
@@ -46,6 +49,10 @@ fun Project.projectTest(taskName: String = "test", body: Test.() -> Unit = {}):
|
||||
val classFileNameWithoutExtension = maybeClassFqName.replace('.', '/')
|
||||
val classFileName = "$classFileNameWithoutExtension.class"
|
||||
|
||||
if (isClassPattern) {
|
||||
filter.includePatterns.add("$pattern$*")
|
||||
}
|
||||
|
||||
include {
|
||||
val path = it.path
|
||||
if (it.isDirectory) {
|
||||
|
||||
Reference in New Issue
Block a user