[Gradle] Support Gradle Configuration Cache with KotlinNativeTest
This commit is contained in:
+11
-4
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.logging.configuration.WarningMode
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.GenerateProjectStructureMetadata
|
import org.jetbrains.kotlin.gradle.plugin.mpp.GenerateProjectStructureMetadata
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.TransformKotlinGranularMetadata
|
import org.jetbrains.kotlin.gradle.plugin.mpp.TransformKotlinGranularMetadata
|
||||||
@@ -82,20 +83,22 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
fun testNativeTasks(gradleVersion: GradleVersion) {
|
fun testNativeTasks(gradleVersion: GradleVersion) {
|
||||||
project("native-configuration-cache", gradleVersion) {
|
project("native-configuration-cache", gradleVersion) {
|
||||||
//testConfigurationCacheOf("assemble", checkUpToDateOnRebuild = false)
|
// testConfigurationCacheOf("build", checkUpToDateOnRebuild = false)
|
||||||
|
|
||||||
val buildOptions = buildOptions.copy(
|
val buildOptions = buildOptions.copy(
|
||||||
configurationCache = true,
|
configurationCache = true,
|
||||||
configurationCacheProblems = BaseGradleIT.ConfigurationCacheProblems.FAIL
|
configurationCacheProblems = BaseGradleIT.ConfigurationCacheProblems.FAIL,
|
||||||
|
warningMode = WarningMode.All
|
||||||
)
|
)
|
||||||
// These tasks currently don't support Configuration Cache and marked as [Task::notCompatibleWithConfigurationCache]
|
// These tasks currently don't support Configuration Cache and marked as [Task::notCompatibleWithConfigurationCache]
|
||||||
val configCacheIncompatibleTaskTypes = listOf(
|
val configCacheIncompatibleTaskTypes = listOf(
|
||||||
GenerateProjectStructureMetadata::class,
|
GenerateProjectStructureMetadata::class,
|
||||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
@Suppress("INVISIBLE_REFERENCE")
|
||||||
org.jetbrains.kotlin.gradle.targets.native.internal.CInteropMetadataDependencyTransformationTask::class,
|
org.jetbrains.kotlin.gradle.targets.native.internal.CInteropMetadataDependencyTransformationTask::class,
|
||||||
TransformKotlinGranularMetadata::class
|
TransformKotlinGranularMetadata::class
|
||||||
).map { it.java.name.replace(".", "\\.") }
|
).map { it.java.name.replace(".", "\\.") }
|
||||||
|
|
||||||
build("assemble", buildOptions = buildOptions) {
|
build("build", buildOptions = buildOptions) {
|
||||||
// Reduce the problem numbers when a Task become compatible with GCC.
|
// Reduce the problem numbers when a Task become compatible with GCC.
|
||||||
// When all tasks support GCC, replace these assertions with `testConfigurationCacheOf`
|
// When all tasks support GCC, replace these assertions with `testConfigurationCacheOf`
|
||||||
assertOutputContains("17 problems were found storing the configuration cache, 6 of which seem unique.")
|
assertOutputContains("17 problems were found storing the configuration cache, 6 of which seem unique.")
|
||||||
@@ -105,6 +108,10 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
|
|||||||
.toRegex()
|
.toRegex()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Enable `warningMode = Fail` back and remove these asserts when KGP supports Gradle 8.0
|
||||||
|
assertOutputContains("The TestReport.destinationDir property has been deprecated.")
|
||||||
|
assertOutputContains("The TestReport.reportOn(Object...) method has been deprecated.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -31,6 +31,14 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
val commonTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinArtifacts {
|
kotlinArtifacts {
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
class CommonTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun sampleTest() {
|
||||||
|
assertEquals("bar42", foo())
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-6
@@ -74,6 +74,14 @@ abstract class KotlinNativeTest : KotlinTest() {
|
|||||||
|
|
||||||
private val trackedEnvironmentVariablesKeys = mutableSetOf<String>()
|
private val trackedEnvironmentVariablesKeys = mutableSetOf<String>()
|
||||||
|
|
||||||
|
private val hasTCProjectProperty = if (isConfigurationCacheAvailable(project.gradle)) {
|
||||||
|
project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent
|
||||||
|
} else {
|
||||||
|
project.hasProperty(TC_PROJECT_PROPERTY)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val konanVersion = project.konanVersion
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@get:Input
|
@get:Input
|
||||||
val trackedEnvironment
|
val trackedEnvironment
|
||||||
@@ -136,18 +144,14 @@ abstract class KotlinNativeTest : KotlinTest() {
|
|||||||
prependSuiteName = targetName != null,
|
prependSuiteName = targetName != null,
|
||||||
treatFailedTestOutputAsStacktrace = false,
|
treatFailedTestOutputAsStacktrace = false,
|
||||||
stackTraceParser = ::parseKotlinNativeStackTraceAsJvm,
|
stackTraceParser = ::parseKotlinNativeStackTraceAsJvm,
|
||||||
escapeTCMessagesInLog = if (isConfigurationCacheAvailable(project.gradle)) {
|
escapeTCMessagesInLog = hasTCProjectProperty
|
||||||
project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent
|
|
||||||
} else {
|
|
||||||
project.hasProperty(TC_PROJECT_PROPERTY)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The KotlinTest expects that the exit code is zero even if some tests failed.
|
// The KotlinTest expects that the exit code is zero even if some tests failed.
|
||||||
// In this case it can check exit code and distinguish test failures from crashes.
|
// In this case it can check exit code and distinguish test failures from crashes.
|
||||||
// But K/N allows forcing a zero exit code only since 1.3 (which was included in Kotlin 1.3.40).
|
// But K/N allows forcing a zero exit code only since 1.3 (which was included in Kotlin 1.3.40).
|
||||||
// Thus we check the exit code only for newer versions.
|
// Thus we check the exit code only for newer versions.
|
||||||
val checkExitCode = project.konanVersion.isAtLeast(1, 3, 0)
|
val checkExitCode = konanVersion.isAtLeast(1, 3, 0)
|
||||||
|
|
||||||
val cliArgs = testCommand.cliArgs("TEAMCITY", checkExitCode, includePatterns, excludePatterns, args)
|
val cliArgs = testCommand.cliArgs("TEAMCITY", checkExitCode, includePatterns, excludePatterns, args)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user