From 905423aa1719bfc60bbe717a641f897a7159711c Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 18 Jan 2024 15:53:37 +0100 Subject: [PATCH] [kotlin-test] Reconfigure JVM unit tests - Include common annotations and assertions test source sets into each test platform test compilation in order to check how they work with that platform's annotations and asserter - Run these tests without platform support jar to check the default asserter implementation --- libraries/kotlin.test/build.gradle.kts | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/libraries/kotlin.test/build.gradle.kts b/libraries/kotlin.test/build.gradle.kts index 2a302e6766a..71de8c04f44 100644 --- a/libraries/kotlin.test/build.gradle.kts +++ b/libraries/kotlin.test/build.gradle.kts @@ -159,6 +159,7 @@ kotlin { } } val jvmJUnitTest by getting { + dependsOn(commonTest) kotlin.srcDir("junit/src/test/kotlin") } val jvmJUnit5 by getting { @@ -170,6 +171,7 @@ kotlin { } } val jvmJUnit5Test by getting { + dependsOn(commonTest) kotlin.srcDir("junit5/src/test/kotlin") dependencies { runtimeOnly(libs.junit.jupiter.engine) @@ -185,6 +187,7 @@ kotlin { } } val jvmTestNGTest by getting { + dependsOn(commonTest) kotlin.srcDir("testng/src/test/kotlin") dependencies { implementation("org.testng:testng:7.5.1") @@ -266,16 +269,23 @@ tasks { dependsOn(jvmJarTasks) } - val jvmTestTasks = jvmTestFrameworks.map { framework -> - register("jvm${framework}Test", Test::class) { - group = "verification" - val compilation = kotlin.jvm().compilations["${framework}Test"] - classpath = compilation.runtimeDependencyFiles + compilation.output.allOutputs - testClassesDirs = compilation.output.classesDirs - when (framework) { - JvmTestFramework.JUnit -> useJUnit() - JvmTestFramework.JUnit5 -> useJUnitPlatform() - JvmTestFramework.TestNG -> useTestNG() + val jvmTestTasks = jvmTestFrameworks.flatMap { framework -> + listOf(false, true).map { excludeAsserterContributor -> + register("jvm${framework}${if (excludeAsserterContributor) "NoAsserter" else ""}Test", Test::class) { + group = "verification" + val testCompilation = kotlin.jvm().compilations["${framework}Test"] + classpath = testCompilation.runtimeDependencyFiles + testCompilation.output.allOutputs + if (excludeAsserterContributor) { + val mainCompilation = kotlin.jvm().compilations["$framework"] + classpath -= mainCompilation.output.allOutputs + filter.excludePatterns += "*ContributorTest" + } + testClassesDirs = testCompilation.output.classesDirs + when (framework) { + JvmTestFramework.JUnit -> useJUnit() + JvmTestFramework.JUnit5 -> useJUnitPlatform() + JvmTestFramework.TestNG -> useTestNG() + } } } }