From 87dd357ec649b6f4f0082fce682d86f3edcd452b Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Sun, 27 Jun 2021 21:35:54 +0200 Subject: [PATCH] Add Gradle test task to run Gradle and Kotlin daemon tests. These tests could not run in parallel, as they could not share Gradle or Kotlin daemons with other running in parallel tests. ^KT-45745 In Progress --- .../build.gradle.kts | 29 ++++++++++--------- .../kotlin/gradle/testbase/testTags.kt | 8 +++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts index d47ad3c21d2..a9f2610501b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts @@ -172,9 +172,23 @@ val simpleTestsTask = tasks.register("kgpSimpleTests") { } } +// Daemon tests could run only sequentially as they could not be shared between parallel test builds +val daemonsTestsTask = tasks.register("kgpDaemonTests") { + group = KGP_TEST_TASKS_GROUP + description = "Run only Gradle and Kotlin daemon tests for Kotlin Gradle Plugin" + maxParallelForks = 1 + + mustRunAfter(simpleTestsTask) + + useJUnitPlatform { + includeTags("DaemonsKGP") + includeEngines("junit-jupiter") + } +} + tasks.named("check") { dependsOn("testAdvanceGradleVersion") - dependsOn(simpleTestsTask) + dependsOn(simpleTestsTask, daemonsTestsTask) if (isTeamcityBuild) { dependsOn("testAdvanceGradleVersionMppAndAndroid") dependsOn("testMppAndAndroid") @@ -184,17 +198,6 @@ tasks.named("check") { } } -val kgpJunit5Tests = tasks.register("kgpJunit5Tests") { - group = KGP_TEST_TASKS_GROUP - description = "Run only JUnit 5 tests for Kotlin Gradle Plugin" - maxParallelForks = (Runtime.getRuntime().availableProcessors() / 4).coerceAtLeast(1) - - useJUnitPlatform { - includeTags("JUnit5") - includeEngines("junit-jupiter") - } -} - tasks.withType { kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String kotlinOptions.jvmTarget = "1.8" @@ -224,7 +227,7 @@ tasks.withType { val shouldApplyJunitPlatform = name !in setOf( simpleTestsTask.name, - kgpJunit5Tests.name + daemonsTestsTask.name ) if (shouldApplyJunitPlatform) { maxHeapSize = "512m" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/testTags.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/testTags.kt index 8c6e340b8ab..22f64274e00 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/testTags.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/testTags.kt @@ -14,3 +14,11 @@ import org.junit.jupiter.api.Tag @Retention(AnnotationRetention.RUNTIME) @Tag("SimpleKGP") annotation class SimpleGradlePluginTests + +/** + * Add it to test classes performing Gradle or Kotlin daemon checks. + */ +@Target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS) +@Retention(AnnotationRetention.RUNTIME) +@Tag("DaemonsKGP") +annotation class DaemonsGradlePluginTests