Gradle, native, JS: Support excluding tests using TestFilter
TestFilter.excludePatterns was introduced in Gradle 5.0. This patch adds support for this API in native and JS test tasks and deprecates the old property used for test excludes.
This commit is contained in:
+1
-2
@@ -2148,8 +2148,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
.resolve("build/reports/tests/${targetName}Test/classes/com.example.HelloTest.html")
|
||||
.readText()
|
||||
|
||||
if (targetName != nativeHostTargetName && targetName != "ios") // TODO: fix exclude patterns for the Kotlin/Native test tasks
|
||||
assertTrue("secondTest" !in classReportHtml, "Test report should not contain 'secondTest':\n$classReportHtml")
|
||||
assertTrue("secondTest" !in classReportHtml, "Test report should not contain 'secondTest':\n$classReportHtml")
|
||||
}
|
||||
targetsToTest.forEach {
|
||||
checkUnitTestOutput(it)
|
||||
|
||||
+6
-3
@@ -15,6 +15,7 @@ import org.gradle.process.internal.ExecHandleFactory
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.KotlinTestRunnerListener
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesTestExecutor
|
||||
import org.jetbrains.kotlin.gradle.utils.injected
|
||||
import org.jetbrains.kotlin.gradle.utils.isGradleVersionAtLeast
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class KotlinTest : AbstractTestTask() {
|
||||
@@ -22,7 +23,8 @@ abstract class KotlinTest : AbstractTestTask() {
|
||||
@Optional
|
||||
var targetName: String? = null
|
||||
|
||||
@Input
|
||||
@Internal // Taken into account by excludePatterns.
|
||||
@Deprecated("Use filter.excludePatterns instead.", ReplaceWith("filter.excludePatterns"))
|
||||
var excludes = mutableSetOf<String>()
|
||||
|
||||
protected val filterExt: DefaultTestFilter
|
||||
@@ -33,10 +35,11 @@ abstract class KotlinTest : AbstractTestTask() {
|
||||
}
|
||||
|
||||
val includePatterns: Set<String>
|
||||
@Internal get() = filterExt.includePatterns + filterExt.commandLineIncludePatterns
|
||||
@Input get() = filterExt.includePatterns + filterExt.commandLineIncludePatterns
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val excludePatterns: Set<String>
|
||||
@Internal get() = excludes
|
||||
@Input get() = excludes + if (isGradleVersionAtLeast(5, 0)) filterExt.excludePatterns else emptySet()
|
||||
|
||||
@get:Inject
|
||||
open val fileResolver: FileResolver
|
||||
|
||||
Reference in New Issue
Block a user