Add KGPDaemonsBaseTest class as test base for daemons test.

This class will stop Gradle and Kotlin daemons after each test
execution.

^KT-45745 In Progress
This commit is contained in:
Yahor Berdnikau
2021-11-03 10:56:47 +01:00
parent 8ed4279759
commit a6436adc17
4 changed files with 22 additions and 23 deletions
@@ -14,17 +14,10 @@ import org.junit.jupiter.api.DisplayName
import kotlin.test.assertTrue
@DisplayName("Gradle daemon memory leak")
@DaemonsGradlePluginTests
class GradleDaemonMemoryIT : KGPBaseTest() {
class GradleDaemonMemoryIT : KGPDaemonsBaseTest() {
override val defaultBuildOptions: BuildOptions
get() = super.defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
@AfterEach
fun tearDown() {
// Stops Gradle and Kotlin daemons, so new run will start them again
ConnectorServices.reset()
}
// For corresponding documentation, see https://docs.gradle.org/current/userguide/gradle_daemon.html
// Setting user.variant to different value implies a new daemon process will be created.
// In order to stop daemon process, special exit task is used ( System.exit(0) ).
@@ -14,7 +14,7 @@ import org.junit.jupiter.api.DisplayName
@DisplayName("Kapt caching inside Gradle daemon")
@DaemonsGradlePluginTests
class Kapt3AndGradleDaemon : KGPBaseTest() {
class Kapt3AndGradleDaemon : KGPDaemonsBaseTest() {
override val defaultBuildOptions: BuildOptions = super.defaultBuildOptions
.copy(
@@ -25,12 +25,6 @@ class Kapt3AndGradleDaemon : KGPBaseTest() {
)
)
@AfterEach
internal fun tearDown() {
// Stops Gradle and Kotlin daemon, so new run will pick up new jvm arguments
ConnectorServices.reset()
}
@DisplayName("Javac should be loaded only once")
@GradleTest
fun testJavacIsLoadedOnce(gradleVersion: GradleVersion) {
@@ -13,18 +13,11 @@ import org.jetbrains.kotlin.gradle.testbase.*
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.DisplayName
@DaemonsGradlePluginTests
@DisplayName("Kotlin daemon JVM args")
class KotlinDaemonJvmArgsTest : KGPBaseTest() {
class KotlinDaemonJvmArgsTest : KGPDaemonsBaseTest() {
override val defaultBuildOptions: BuildOptions
get() = super.defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
@AfterEach
internal fun tearDown() {
// Stops Gradle and Kotlin daemon, so new run will pick up new jvm arguments
ConnectorServices.reset()
}
@GradleTest
@DisplayName("Kotlin daemon by default should inherit Gradle daemon max jvm heap size")
internal fun shouldInheritGradleDaemonArgsByDefault(gradleVersion: GradleVersion) {
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.testbase
import org.gradle.tooling.internal.consumer.ConnectorServices
import org.junit.jupiter.api.AfterEach
@DaemonsGradlePluginTests
abstract class KGPDaemonsBaseTest : KGPBaseTest() {
@AfterEach
internal open fun tearDown() {
// Stops Gradle and Kotlin daemon, so new run will pick up new jvm arguments
ConnectorServices.reset()
}
}