[Gradle] Add integration test checking 'kotlin.user.home' is possible to change
^KT-58223 In Progress
This commit is contained in:
committed by
Space Team
parent
e8a7c53dde
commit
5413973891
+2
-8
@@ -280,10 +280,7 @@ class BuildReportsIT : KGPBaseTest() {
|
||||
) {
|
||||
|
||||
val lookupsTab = projectPath.resolve("build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab")
|
||||
fun kotlinErrorPath() = tempDir
|
||||
.resolve("projects-1")
|
||||
.findInPath("errors")
|
||||
?: throw IllegalStateException("Could not find global Kotlin errors directory!")
|
||||
fun kotlinErrorPath() = tempDir.inProjectsPersistentCache("errors")
|
||||
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
@@ -334,10 +331,7 @@ class BuildReportsIT : KGPBaseTest() {
|
||||
gradleVersion = gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(kotlinUserHome = tempDir)
|
||||
) {
|
||||
fun kotlinErrorPath() = tempDir
|
||||
.resolve("projects-1")
|
||||
.findInPath("errors")
|
||||
?: throw IllegalStateException("Could not find global Kotlin errors directory!")
|
||||
fun kotlinErrorPath() = tempDir.inProjectsPersistentCache("errors")
|
||||
|
||||
build("compileKotlin", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||
assertOutputDoesNotContain("errors were stored into file")
|
||||
|
||||
+2
-6
@@ -176,9 +176,7 @@ open class CommonizerIT : KGPBaseTest() {
|
||||
|
||||
configureCommonizerTargets()
|
||||
|
||||
fun expectedOutputDirectoryForIde(): Path = tempDir
|
||||
.resolve("projects-1")
|
||||
.findInPath("commonizer") ?: throw IllegalStateException("Failed to find 'commonizer' directory!")
|
||||
fun expectedOutputDirectoryForIde(): Path = tempDir.inProjectsPersistentCache("commonizer")
|
||||
|
||||
val expectedOutputDirectoryForBuild = projectPath.resolve("build/classes/kotlin/commonizer")
|
||||
|
||||
@@ -551,9 +549,7 @@ open class CommonizerIT : KGPBaseTest() {
|
||||
|
||||
configureCommonizerTargets()
|
||||
|
||||
fun expectedOutputDirectoryForIde(): Path = tempDir
|
||||
.resolve("projects-1")
|
||||
.findInPath("commonizer") ?: throw IllegalStateException("Failed to find 'commonizer' directory!")
|
||||
fun expectedOutputDirectoryForIde(): Path = tempDir.inProjectsPersistentCache("commonizer")
|
||||
|
||||
build(":copyCommonizeCInteropForIde") {
|
||||
assertTasksExecuted(":cinteropCurlTargetB")
|
||||
|
||||
+34
@@ -6,8 +6,11 @@ import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Path
|
||||
import java.util.zip.ZipFile
|
||||
import kotlin.io.path.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("KGP simple tests")
|
||||
@@ -289,4 +292,35 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Possible to override kotlin.user.home location")
|
||||
@GradleTest
|
||||
fun overrideKotlinUserHome(
|
||||
gradleVersion: GradleVersion,
|
||||
@TempDir tempDir: Path,
|
||||
) {
|
||||
project(
|
||||
projectName = "simpleProject",
|
||||
gradleVersion = gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(kotlinUserHome = null)
|
||||
) {
|
||||
gradleProperties.appendText(
|
||||
"""
|
||||
|
|
||||
|kotlin.user.home=${tempDir.absolutePathString().normalizePath()}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build("compileKotlin") {
|
||||
assertTasksExecuted(":compileKotlin")
|
||||
|
||||
val baseProjectsDir = tempDir.resolve("projects-1")
|
||||
assertDirectoryExists(baseProjectsDir)
|
||||
val projectsDirs = baseProjectsDir.listDirectoryEntries()
|
||||
assertEquals(1, projectsDirs.size, message = "More then 1 child! Actual content ${projectsDirs.joinToString { it.pathString }}")
|
||||
assertDirectoryExists(projectsDirs.first().resolve("sessions"))
|
||||
assertDirectoryExists(projectsDirs.first().resolve("errors"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -120,3 +120,21 @@ fun Path.getSingleFileInDir(relativePath: String): Path {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a path for per-project persistent cache directory from this base persistent cache directory.
|
||||
*/
|
||||
fun Path.projectsPersistentCache() = resolve("projects-1")
|
||||
|
||||
/**
|
||||
* Searches for the specified directory in the projects persistent cache.
|
||||
*
|
||||
* @param directoryName The name of the directory to search for.
|
||||
* @return The path of the directory if found.
|
||||
*
|
||||
* @throws IllegalStateException if the directory does not exist in the projects cache. Usually they are populated after some build.
|
||||
*/
|
||||
fun Path.inProjectsPersistentCache(
|
||||
directoryName: String
|
||||
) = projectsPersistentCache().findInPath(directoryName)
|
||||
?: throw IllegalStateException("$directoryName does not exist in the projects cache under ${this.absolutePathString()}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user