Explicitly define the set of environment variables needed for tests

This commit is contained in:
Nikolay Krasko
2022-09-22 13:50:22 +02:00
committed by Space
parent 8799b9b751
commit 13a68b0e2d
2 changed files with 8 additions and 7 deletions
+4 -4
View File
@@ -107,6 +107,7 @@ fun Project.projectTest(
maxHeapSizeMb: Int? = null, maxHeapSizeMb: Int? = null,
minHeapSizeMb: Int? = null, minHeapSizeMb: Int? = null,
reservedCodeCacheSizeMb: Int = 256, reservedCodeCacheSizeMb: Int = 256,
defineJDKEnvVariables: List<JdkMajorVersion> = emptyList(),
body: Test.() -> Unit = {} body: Test.() -> Unit = {}
): TaskProvider<Test> { ): TaskProvider<Test> {
val shouldInstrument = project.providers.gradleProperty("kotlin.test.instrumentation.disable") val shouldInstrument = project.providers.gradleProperty("kotlin.test.instrumentation.disable")
@@ -249,10 +250,9 @@ fun Project.projectTest(
?: forks.coerceIn(1, Runtime.getRuntime().availableProcessors()) ?: forks.coerceIn(1, Runtime.getRuntime().availableProcessors())
} }
JdkMajorVersion.values().forEach { version -> defineJDKEnvVariables.forEach { version ->
project.getToolchainLauncherFor(version).orNull?.let { val javaLauncher = project.getToolchainLauncherFor(version).orNull ?: error("Can't find toolchain for $version")
environment(version.envName, it.metadata.installationPath.asFile.absolutePath) environment(version.envName, javaLauncher.metadata.installationPath.asFile.absolutePath)
}
} }
}.apply { configure(body) } }.apply { configure(body) }
} }
+4 -3
View File
@@ -1,5 +1,3 @@
import java.io.File
plugins { plugins {
kotlin("jvm") kotlin("jvm")
id("jps-compatible") id("jps-compatible")
@@ -52,7 +50,10 @@ sourceSets {
} }
} }
projectTest(parallel = true) { projectTest(
parallel = true,
defineJDKEnvVariables = listOf(JdkMajorVersion.JDK_1_8, JdkMajorVersion.JDK_11_0, JdkMajorVersion.JDK_17_0)
) {
dependsOn(":dist") dependsOn(":dist")
workingDir = rootDir workingDir = rootDir