[Build] Extract DefaultTestFilter.commandLineIncludePatterns as a property of Test

This commit is contained in:
Dmitriy Dolovov
2021-12-15 11:45:05 +03:00
parent 341e017261
commit cb115a4088
+4 -1
View File
@@ -115,7 +115,7 @@ fun Project.projectTest(
doFirst {
if (jUnitMode == JUnitMode.JUnit5) return@doFirst
val commandLineIncludePatterns = (filter as? DefaultTestFilter)?.commandLineIncludePatterns?.toMutableList() ?: mutableSetOf()
val commandLineIncludePatterns = commandLineIncludePatterns.toMutableSet()
val patterns = filter.includePatterns + commandLineIncludePatterns
if (patterns.isEmpty() || patterns.any { '*' in it }) return@doFirst
patterns.forEach { pattern ->
@@ -232,6 +232,9 @@ fun Project.projectTest(
}.apply { configure(body) }
}
val Test.commandLineIncludePatterns: Set<String>
get() = (filter as? DefaultTestFilter)?.commandLineIncludePatterns.orEmpty()
private inline fun String.isFirstChar(f: (Char) -> Boolean) = isNotEmpty() && f(first())
inline fun <reified T : Task> Project.getOrCreateTask(taskName: String, noinline body: T.() -> Unit): TaskProvider<T> =