[Gradle] Use for Gradle IT tests custom location for kotlin.user.home

Such way, we could easily clean all persistent storage produced by
test runs.

^KT-58223 In Progress
This commit is contained in:
Yahor Berdnikau
2023-08-14 23:30:46 +02:00
committed by Space Team
parent 3d94679db4
commit e8a7c53dde
3 changed files with 9 additions and 3 deletions
@@ -172,7 +172,7 @@ open class CommonizerIT : KGPBaseTest() {
gradleVersion: GradleVersion,
@TempDir tempDir: Path,
) {
nativeProject("commonizeCurlInterop", gradleVersion) {
nativeProject("commonizeCurlInterop", gradleVersion, buildOptions = defaultBuildOptions.copy(kotlinUserHome = null)) {
configureCommonizerTargets()
@@ -546,7 +546,7 @@ open class CommonizerIT : KGPBaseTest() {
gradleVersion: GradleVersion,
@TempDir tempDir: Path,
) {
nativeProject("commonizeCurlInterop", gradleVersion) {
nativeProject("commonizeCurlInterop", gradleVersion, buildOptions = defaultBuildOptions.copy(kotlinUserHome = null)) {
gradleProperties.append("kotlin.user.home=${tempDir.absolutePathString()}")
configureCommonizerTargets()
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.report.BuildReportType
import org.junit.jupiter.api.condition.OS
import java.nio.file.Path
import java.util.*
import kotlin.io.path.absolutePathString
data class BuildOptions(
val logLevel: LogLevel = LogLevel.INFO,
@@ -53,6 +54,7 @@ data class BuildOptions(
val compilerExecutionStrategy: KotlinCompilerExecutionStrategy? = null,
val runViaBuildToolsApi: Boolean? = null,
val konanDataDir: Path? = konanDir, // null can be used only if you are using custom 'kotlin.native.home' or 'org.jetbrains.kotlin.native.home' property instead of konanDir
val kotlinUserHome: Path? = testKitDir.resolve(".kotlin"),
) {
val isK2ByDefault
get() = KotlinVersion.DEFAULT >= KotlinVersion.KOTLIN_2_0
@@ -217,6 +219,10 @@ data class BuildOptions(
arguments.add("-Pkonan.data.dir=${konanDataDir.toAbsolutePath().normalize()}")
}
if (kotlinUserHome != null) {
arguments.add("-Pkotlin.user.home=${kotlinUserHome.absolutePathString()}")
}
arguments.addAll(freeArgs)
return arguments.toList()
@@ -489,7 +489,7 @@ val konanDir
/**
* On changing test kit dir location update related location in 'cleanTestKitCache' task.
*/
private val testKitDir get() = Paths.get(".").resolve("build").resolve("testKitCache")
internal val testKitDir get() = Paths.get(".").resolve("build").resolve("testKitCache")
private val hashAlphabet: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9')
private fun randomHash(length: Int = 15): String {