Disable test optimization on patterns with wildcards
This commit is contained in:
committed by
Ilya Chernikov
parent
34ac3a818a
commit
98413f200f
@@ -9,22 +9,21 @@ import org.gradle.kotlin.dsl.extra
|
|||||||
fun Project.projectTest(body: Test.() -> Unit = {}): Test = (tasks.findByName("test") as Test).apply {
|
fun Project.projectTest(body: Test.() -> Unit = {}): Test = (tasks.findByName("test") as Test).apply {
|
||||||
doFirst {
|
doFirst {
|
||||||
val patterns = filter.includePatterns + ((filter as? DefaultTestFilter)?.commandLineIncludePatterns ?: emptySet())
|
val patterns = filter.includePatterns + ((filter as? DefaultTestFilter)?.commandLineIncludePatterns ?: emptySet())
|
||||||
if (!patterns.isEmpty()) {
|
if (patterns.isEmpty() || patterns.any { '*' in it }) return@doFirst
|
||||||
patterns.forEach { pattern ->
|
patterns.forEach { pattern ->
|
||||||
val maybeMethodName = pattern.substringAfterLast('.')
|
val maybeMethodName = pattern.substringAfterLast('.')
|
||||||
val className = if (maybeMethodName.isNotEmpty() && maybeMethodName[0].isLowerCase())
|
val className = if (maybeMethodName.isNotEmpty() && maybeMethodName[0].isLowerCase())
|
||||||
pattern.substringBeforeLast('.')
|
pattern.substringBeforeLast('.')
|
||||||
else
|
else
|
||||||
pattern
|
pattern
|
||||||
|
|
||||||
val matchPattern = className.replace('.', '/') + ".class"
|
val matchPattern = className.replace('.', '/') + ".class"
|
||||||
|
|
||||||
include {
|
include {
|
||||||
if (it.isDirectory) {
|
if (it.isDirectory) {
|
||||||
matchPattern.startsWith(it.path)
|
matchPattern.startsWith(it.path)
|
||||||
} else {
|
} else {
|
||||||
it.path.endsWith(matchPattern)
|
it.path.endsWith(matchPattern)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user