Add tasks and annotations for Gradle/Jvm and Gradle/Js tests.
We will split our tests into supported platforms, like JVM, Js, etc... Tests for supported Gradle features should be added per platform. To run any test (except daemons) also "all" task was added. ^KT-45745 In Progress
This commit is contained in:
@@ -161,11 +161,24 @@ if (isTeamcityBuild) {
|
||||
}
|
||||
|
||||
val KGP_TEST_TASKS_GROUP = "Kotlin Gradle Plugin Verification"
|
||||
val maxParallelTestForks = (Runtime.getRuntime().availableProcessors() / 4).coerceAtLeast(1)
|
||||
|
||||
val allParallelTestsTask = tasks.register<Test>("kgpAllParallelTests") {
|
||||
group = KGP_TEST_TASKS_GROUP
|
||||
description = "Runs all tests for Kotlin Gradle plugins except daemon ones"
|
||||
|
||||
maxParallelForks = maxParallelTestForks
|
||||
|
||||
useJUnitPlatform {
|
||||
excludeTags("DaemonsKGP")
|
||||
includeEngines("junit-jupiter")
|
||||
}
|
||||
}
|
||||
|
||||
val simpleTestsTask = tasks.register<Test>("kgpSimpleTests") {
|
||||
group = KGP_TEST_TASKS_GROUP
|
||||
description = "Run only simple tests for Kotlin Gradle Plugin"
|
||||
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 4).coerceAtLeast(1)
|
||||
description = "Run only simple tests for Kotlin Gradle Plugin (deprecated)"
|
||||
maxParallelForks = maxParallelTestForks
|
||||
|
||||
useJUnitPlatform {
|
||||
includeTags("SimpleKGP")
|
||||
@@ -173,6 +186,26 @@ val simpleTestsTask = tasks.register<Test>("kgpSimpleTests") {
|
||||
}
|
||||
}
|
||||
|
||||
val jvmTestsTask = tasks.register<Test>("kgpJvmTests") {
|
||||
group = KGP_TEST_TASKS_GROUP
|
||||
description = "Run tests for Kotlin/JVM part of Gradle plugin"
|
||||
maxParallelForks = maxParallelTestForks
|
||||
useJUnitPlatform {
|
||||
includeTags("JvmKGP")
|
||||
includeEngines("junit-jupiter")
|
||||
}
|
||||
}
|
||||
|
||||
val jsTestsTask = tasks.register<Test>("kgpJsTests") {
|
||||
group = KGP_TEST_TASKS_GROUP
|
||||
description = "Run tests for Kotlin/JS part of Gradle plugin"
|
||||
maxParallelForks = maxParallelTestForks
|
||||
useJUnitPlatform {
|
||||
includeTags("JsKGP")
|
||||
includeEngines("junit-jupiter")
|
||||
}
|
||||
}
|
||||
|
||||
// Daemon tests could run only sequentially as they could not be shared between parallel test builds
|
||||
val daemonsTestsTask = tasks.register<Test>("kgpDaemonTests") {
|
||||
group = KGP_TEST_TASKS_GROUP
|
||||
@@ -189,7 +222,7 @@ val daemonsTestsTask = tasks.register<Test>("kgpDaemonTests") {
|
||||
|
||||
tasks.named<Task>("check") {
|
||||
dependsOn("testAdvanceGradleVersion")
|
||||
dependsOn(simpleTestsTask, daemonsTestsTask)
|
||||
dependsOn(simpleTestsTask, jvmTestsTask, jsTestsTask, daemonsTestsTask)
|
||||
if (isTeamcityBuild) {
|
||||
dependsOn("testAdvanceGradleVersionMppAndAndroid")
|
||||
dependsOn("testMppAndAndroid")
|
||||
@@ -234,7 +267,10 @@ tasks.withType<Test> {
|
||||
useAndroidSdk()
|
||||
|
||||
val shouldApplyJunitPlatform = name !in setOf(
|
||||
allParallelTestsTask.name,
|
||||
simpleTestsTask.name,
|
||||
jvmTestsTask.name,
|
||||
jsTestsTask.name,
|
||||
daemonsTestsTask.name
|
||||
)
|
||||
if (shouldApplyJunitPlatform) {
|
||||
|
||||
+18
-2
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.gradle.testbase
|
||||
import org.junit.jupiter.api.Tag
|
||||
|
||||
/**
|
||||
* Add it to test classes performing simple KGP checks.
|
||||
* Add it to test classes performing simple KGP checks (deprecated).
|
||||
*/
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@@ -18,7 +18,23 @@ annotation class SimpleGradlePluginTests
|
||||
/**
|
||||
* Add it to test classes performing Gradle or Kotlin daemon checks.
|
||||
*/
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@Tag("DaemonsKGP")
|
||||
annotation class DaemonsGradlePluginTests
|
||||
|
||||
/**
|
||||
* Add it to tests covering Kotlin Gradle Plugin/JVM platform.
|
||||
*/
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@Tag("JvmKGP")
|
||||
annotation class JvmGradlePluginTests
|
||||
|
||||
/**
|
||||
* Add it to tests covering Kotlin Gradle Plugin/JS platform.
|
||||
*/
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@Tag("JsKGP")
|
||||
annotation class JsGradlePluginTests
|
||||
Reference in New Issue
Block a user