migrated NativeIrLinkerIssuesIT to junit 5 and gradle TestKit

#KT-51553 In Progress

Merge-request: KT-MR-9921
Merged-by: Dmitrii Krasnov <Dmitrii.Krasnov@jetbrains.com>
This commit is contained in:
Dmitrii Krasnov
2023-05-08 13:22:36 +00:00
committed by Space Team
parent cbcd68cd85
commit af4ef048be
12 changed files with 143 additions and 127 deletions
@@ -1,48 +1,51 @@
/* /*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2023 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. * 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.native package org.jetbrains.kotlin.gradle.native
import org.jetbrains.kotlin.gradle.BaseGradleIT import org.gradle.api.logging.LogLevel
import org.jetbrains.kotlin.gradle.GradleVersionRequired import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.getOutputForTask import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
import org.jetbrains.kotlin.gradle.testbase.DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX import org.jetbrains.kotlin.gradle.testbase.*
import org.jetbrains.kotlin.gradle.testbase.findParameterInOutput
import org.jetbrains.kotlin.konan.library.KONAN_PLATFORM_LIBS_NAME_PREFIX import org.jetbrains.kotlin.konan.library.KONAN_PLATFORM_LIBS_NAME_PREFIX
import org.jetbrains.kotlin.konan.target.HostManager import org.junit.jupiter.api.Disabled
import org.jetbrains.kotlin.konan.target.KonanTarget import org.junit.jupiter.api.DisplayName
import org.junit.Assume.assumeFalse import org.junit.jupiter.api.condition.DisabledOnOs
import org.junit.Assume.assumeTrue import org.junit.jupiter.api.condition.OS
import org.junit.Ignore import org.junit.jupiter.api.io.TempDir
import org.junit.Test import java.nio.file.Path
import java.io.File
import java.nio.file.Files
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertNotNull import kotlin.test.assertNotNull
class NativeIrLinkerIssuesIT : BaseGradleIT() { @DisplayName("Tests for K/N builds with ir linker issues")
override val defaultGradleVersion: GradleVersionRequired @NativeGradlePluginTests
get() = GradleVersionRequired.FOR_MPP_SUPPORT internal class NativeIrLinkerIssuesIT : KGPBaseTest() {
@Test @DisplayName("KT-46697: ktor 1_5_4 and coroutines 1_5_0-RC-native-mt")
@Ignore( @GradleTest
@Disabled(
"This sample fails in a way that was not expected because kotlin/Experimental annotation that is still used in ktor 1.5.4" + "This sample fails in a way that was not expected because kotlin/Experimental annotation that is still used in ktor 1.5.4" +
" was removed in stdlib in 1.8. We need to find another appropriate sample to replace this one." " was removed in stdlib in 1.8. We need to find another appropriate sample to replace this one."
) )
fun `ktor 1_5_4 and coroutines 1_5_0-RC-native-mt (KT-46697)`() { // TODO: consider finding a newer versions that support arm64 and reproduce this issue
// Run this test only on macOS x64, @DisabledOnOs(
// arm64 requires newer ktor (>=1.6.5) and coroutines (>=1.5.2-native-mt) OS.MAC,
// that compatible to each other and don't fail this way. architectures = ["aarch64"],
// TODO: consider finding a newer versions that support arm64 and reproduce this issue disabledReason =
assumeTrue(HostManager.host == KonanTarget.MACOS_X64) "Run this test only on macOS x64," +
" arm64 requires newer ktor (>=1.6.5) and coroutines (>=1.5.2-native-mt) " +
"that compatible to each other and don't fail this way."
)
fun shouldBuildKtorAndCoroutines(gradleVersion: GradleVersion) {
buildApplicationAndFail( buildApplicationAndFail(
directoryPrefix = null, directoryPrefix = null,
projectName = "native-ir-linker-issues-ktor-and-coroutines", projectName = "native-ir-linker-issues-ktor-and-coroutines",
localRepo = null, localRepo = null,
useCache = true nativeCacheKind = NativeCacheKind.STATIC,
gradleVersion = gradleVersion
) { kotlinNativeCompilerVersion -> ) { kotlinNativeCompilerVersion ->
""" """
|e: The symbol of unexpected type encountered during IR deserialization: IrTypeAliasPublicSymbolImpl, kotlinx.coroutines/CancellationException|null[0]. IrClassifierSymbol is expected. |e: The symbol of unexpected type encountered during IR deserialization: IrTypeAliasPublicSymbolImpl, kotlinx.coroutines/CancellationException|null[0]. IrClassifierSymbol is expected.
@@ -117,14 +120,19 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() {
} }
} }
@Test @DisplayName("KT-41378: declaration that is gone - with cache")
fun `declaration that is gone (KT-41378) - with cache`() { @GradleTest
// Don't run it on Windows. Caches are not supported there yet. @DisabledOnOs(OS.WINDOWS, disabledReason = "Don't run it on Windows. Caches are not supported there yet.")
assumeFalse(HostManager.hostIsMingw) fun shouldBuildIrLinkerWithCache(
gradleVersion: GradleVersion,
@TempDir tempDir: Path,
) {
buildConflictingLibrariesAndApplication( buildConflictingLibrariesAndApplication(
directoryPrefix = "native-ir-linker-issues-gone-declaration", directoryPrefix = "native-ir-linker-issues-gone-declaration",
useCache = true nativeCacheKind = NativeCacheKind.STATIC,
gradleVersion = gradleVersion,
localRepo = tempDir
) { kotlinNativeCompilerVersion -> ) { kotlinNativeCompilerVersion ->
""" """
|e: Module "org.sample:libb (org.sample:libb-native)" has a reference to symbol sample.liba/C|null[0]. Neither the module itself nor its dependencies contain such declaration. |e: Module "org.sample:libb (org.sample:libb-native)" has a reference to symbol sample.liba/C|null[0]. Neither the module itself nor its dependencies contain such declaration.
@@ -147,11 +155,17 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() {
} }
} }
@Test @DisplayName("KT-41378: declaration that is gone - without cache")
fun `declaration that is gone (KT-41378) - without cache`() { @GradleTest
fun shouldBuildIrLinkerWithoutCache(
gradleVersion: GradleVersion,
@TempDir tempDir: Path,
) {
buildConflictingLibrariesAndApplication( buildConflictingLibrariesAndApplication(
directoryPrefix = "native-ir-linker-issues-gone-declaration", directoryPrefix = "native-ir-linker-issues-gone-declaration",
useCache = false nativeCacheKind = NativeCacheKind.NONE,
gradleVersion = gradleVersion,
localRepo = tempDir
) { kotlinNativeCompilerVersion -> ) { kotlinNativeCompilerVersion ->
""" """
|e: Module "org.sample:libb (org.sample:libb-native)" has a reference to symbol sample.liba/C|null[0]. Neither the module itself nor its dependencies contain such declaration. |e: Module "org.sample:libb (org.sample:libb-native)" has a reference to symbol sample.liba/C|null[0]. Neither the module itself nor its dependencies contain such declaration.
@@ -176,14 +190,17 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() {
} }
} }
@Test @DisplayName("KT-47285: symbol type mismatch - with cache")
fun `symbol type mismatch (KT-47285) - with cache`() { @GradleTest
// Don't run it on Windows. Caches are not supported there yet. fun shouldBuildIrLinkerSymbolTypeMismatchWithCache(
assumeFalse(HostManager.hostIsMingw) gradleVersion: GradleVersion,
@TempDir tempDir: Path,
) {
buildConflictingLibrariesAndApplication( buildConflictingLibrariesAndApplication(
directoryPrefix = "native-ir-linker-issues-symbol-mismatch", directoryPrefix = "native-ir-linker-issues-symbol-mismatch",
useCache = true nativeCacheKind = NativeCacheKind.STATIC,
gradleVersion = gradleVersion,
localRepo = tempDir
) { kotlinNativeCompilerVersion -> ) { kotlinNativeCompilerVersion ->
""" """
|e: The symbol of unexpected type encountered during IR deserialization: IrTypeAliasPublicSymbolImpl, sample.liba/B|null[0]. IrClassifierSymbol is expected. |e: The symbol of unexpected type encountered during IR deserialization: IrTypeAliasPublicSymbolImpl, sample.liba/B|null[0]. IrClassifierSymbol is expected.
@@ -207,11 +224,17 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() {
} }
} }
@Test @DisplayName("KT-47285: symbol type mismatch - without cache")
fun `symbol type mismatch (KT-47285) - without cache`() { @GradleTest
fun shouldBuildIrLinkerSymbolTypeMismatchWithoutCache(
gradleVersion: GradleVersion,
@TempDir tempDir: Path,
) {
buildConflictingLibrariesAndApplication( buildConflictingLibrariesAndApplication(
directoryPrefix = "native-ir-linker-issues-symbol-mismatch", directoryPrefix = "native-ir-linker-issues-symbol-mismatch",
useCache = false nativeCacheKind = NativeCacheKind.NONE,
gradleVersion = gradleVersion,
localRepo = tempDir
) { kotlinNativeCompilerVersion -> ) { kotlinNativeCompilerVersion ->
""" """
|e: The symbol of unexpected type encountered during IR deserialization: IrTypeAliasPublicSymbolImpl, sample.liba/B|null[0]. IrClassifierSymbol is expected. |e: The symbol of unexpected type encountered during IR deserialization: IrTypeAliasPublicSymbolImpl, sample.liba/B|null[0]. IrClassifierSymbol is expected.
@@ -239,20 +262,21 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() {
private fun buildConflictingLibrariesAndApplication( private fun buildConflictingLibrariesAndApplication(
directoryPrefix: String, directoryPrefix: String,
useCache: Boolean, nativeCacheKind: NativeCacheKind,
expectedErrorMessage: (compilerVersion: String) -> String gradleVersion: GradleVersion,
localRepo: Path,
expectedErrorMessage: (compilerVersion: String) -> String,
) { ) {
val repo = setupLocalRepo() buildAndPublishLibrary(directoryPrefix = directoryPrefix, projectName = "liba-v1.0", localRepo = localRepo, gradleVersion)
buildAndPublishLibrary(directoryPrefix = directoryPrefix, projectName = "liba-v2.0", localRepo = localRepo, gradleVersion)
buildAndPublishLibrary(directoryPrefix = directoryPrefix, projectName = "liba-v1.0", localRepo = repo) buildAndPublishLibrary(directoryPrefix = directoryPrefix, projectName = "libb", localRepo = localRepo, gradleVersion)
buildAndPublishLibrary(directoryPrefix = directoryPrefix, projectName = "liba-v2.0", localRepo = repo)
buildAndPublishLibrary(directoryPrefix = directoryPrefix, projectName = "libb", localRepo = repo)
buildApplicationAndFail( buildApplicationAndFail(
directoryPrefix = directoryPrefix, directoryPrefix = directoryPrefix,
projectName = "app", projectName = "app",
localRepo = repo, localRepo = localRepo,
useCache = useCache, nativeCacheKind = nativeCacheKind,
gradleVersion = gradleVersion,
expectedErrorMessage = expectedErrorMessage expectedErrorMessage = expectedErrorMessage
) )
} }
@@ -260,22 +284,20 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() {
private fun buildApplicationAndFail( private fun buildApplicationAndFail(
directoryPrefix: String?, directoryPrefix: String?,
projectName: String, projectName: String,
localRepo: File?, localRepo: Path?,
useCache: Boolean, nativeCacheKind: NativeCacheKind,
expectedErrorMessage: (compilerVersion: String) -> String gradleVersion: GradleVersion,
expectedErrorMessage: (compilerVersion: String) -> String,
) { ) {
prepareProject(directoryPrefix, projectName, localRepo, useCache) { prepareProject(directoryPrefix, projectName, localRepo, nativeCacheKind, gradleVersion) {
build("linkDebugExecutableNative") { buildAndFail("linkDebugExecutableNative", buildOptions = this.buildOptions.copy(logLevel = LogLevel.DEBUG)) {
assertFailed()
val kotlinNativeCompilerVersion = findKotlinNativeCompilerVersion(output) val kotlinNativeCompilerVersion = findKotlinNativeCompilerVersion(output)
assertNotNull(kotlinNativeCompilerVersion) assertNotNull(kotlinNativeCompilerVersion)
val errorMessage = ERROR_LINE_REGEX.findAll(getOutputForTask(":linkDebugExecutableNative")) val errorMessage = ERROR_LINE_REGEX.findAll(getOutputForTask(":linkDebugExecutableNative"))
.map { matchResult -> matchResult.groupValues[1] } .map { matchResult -> matchResult.groupValues[1] }
.filterNot { it.startsWith("w:") || it.startsWith("v:") || it.startsWith("i:") } .filterNot { it.startsWith("w:") || it.startsWith("v:") || it.startsWith("i:") }.map { line ->
.map { line ->
line.replace(COMPRESSED_PLATFORM_LIBS_REGEX) { result -> line.replace(COMPRESSED_PLATFORM_LIBS_REGEX) { result ->
val rangeWithPlatformLibrariesCount = result.groups[1]!!.range val rangeWithPlatformLibrariesCount = result.groups[1]!!.range
buildString { buildString {
@@ -284,39 +306,35 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() {
append(line.substring(rangeWithPlatformLibrariesCount.last + 1)) append(line.substring(rangeWithPlatformLibrariesCount.last + 1))
} }
} }
} }.joinToString("\n")
.joinToString("\n")
assertEquals(expectedErrorMessage(kotlinNativeCompilerVersion), errorMessage) assertEquals(expectedErrorMessage(kotlinNativeCompilerVersion), errorMessage)
} }
} }
} }
private fun buildAndPublishLibrary(directoryPrefix: String, projectName: String, localRepo: File) { private fun buildAndPublishLibrary(
prepareProject(directoryPrefix, projectName, localRepo, useCache = true) { directoryPrefix: String, projectName: String, localRepo: Path, gradleVersion: GradleVersion,
build("publish") { ) {
assertSuccessful() prepareProject(directoryPrefix, projectName, localRepo, nativeCacheKind = NativeCacheKind.STATIC, gradleVersion) {
} build("publish")
} }
} }
private fun prepareProject( private fun prepareProject(
directoryPrefix: String?, directoryPrefix: String?,
projectName: String, projectName: String,
localRepo: File?, localRepo: Path?,
useCache: Boolean, nativeCacheKind: NativeCacheKind,
block: Project.() -> Unit gradleVersion: GradleVersion,
block: TestProject.() -> Unit,
) { ) {
with(transformNativeTestProjectWithPluginDsl(directoryPrefix = directoryPrefix, projectName = projectName)) { nativeProject(
if (localRepo != null) { directoryPrefix + "/" + projectName,
val localRepoUri = localRepo.absoluteFile.toURI().toString() gradleVersion = gradleVersion,
gradleBuildScript().apply { buildOptions = defaultBuildOptions.copy(nativeCacheKind = nativeCacheKind),
writeText(readText().replace("<LocalRepo>", localRepoUri)) localRepoDir = localRepo
} ) {
}
gradleProperties().appendText("\nkotlin.native.cacheKind=${if (useCache) "static" else "none"}\n")
block() block()
} }
} }
@@ -326,9 +344,7 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() {
private val COMPRESSED_PLATFORM_LIBS_REGEX = private val COMPRESSED_PLATFORM_LIBS_REGEX =
".*${KONAN_PLATFORM_LIBS_NAME_PREFIX.replace(".", "\\.")}\\* \\((\\d+) libraries\\).*".toRegex() ".*${KONAN_PLATFORM_LIBS_NAME_PREFIX.replace(".", "\\.")}\\* \\((\\d+) libraries\\).*".toRegex()
private fun setupLocalRepo(): File = Files.createTempDirectory("localRepo").toAbsolutePath().toFile() private fun findKotlinNativeCompilerVersion(output: String): String? = findParameterInOutput(
fun findKotlinNativeCompilerVersion(output: String): String? = findParameterInOutput(
"for_test_kotlin_native_compiler_version", "for_test_kotlin_native_compiler_version",
output output
) )
@@ -10,6 +10,7 @@ import org.gradle.api.logging.configuration.WarningMode
import org.gradle.util.GradleVersion import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM import org.jetbrains.kotlin.cli.common.CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM
import org.jetbrains.kotlin.gradle.BaseGradleIT import org.jetbrains.kotlin.gradle.BaseGradleIT
import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
import org.jetbrains.kotlin.gradle.report.BuildReportType import org.jetbrains.kotlin.gradle.report.BuildReportType
import org.junit.jupiter.api.condition.OS import org.junit.jupiter.api.condition.OS
@@ -43,6 +44,7 @@ data class BuildOptions(
val keepIncrementalCompilationCachesInMemory: Boolean? = null, val keepIncrementalCompilationCachesInMemory: Boolean? = null,
val useDaemonFallbackStrategy: Boolean = false, val useDaemonFallbackStrategy: Boolean = false,
val verboseDiagnostics: Boolean = true, val verboseDiagnostics: Boolean = true,
val nativeCacheKind: NativeCacheKind = NativeCacheKind.NONE
) { ) {
val safeAndroidVersion: String val safeAndroidVersion: String
get() = androidVersion ?: error("AGP version is expected to be set") get() = androidVersion ?: error("AGP version is expected to be set")
@@ -170,6 +172,8 @@ data class BuildOptions(
arguments.add("-Pkotlin.internal.verboseDiagnostics=$verboseDiagnostics") arguments.add("-Pkotlin.internal.verboseDiagnostics=$verboseDiagnostics")
} }
arguments.add("-Pkotlin.native.cacheKind=${nativeCacheKind.name.lowercase()}")
arguments.addAll(freeArgs) arguments.addAll(freeArgs)
return arguments.toList() return arguments.toList()
@@ -13,7 +13,6 @@ import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.BaseGradleIT.Companion.acceptAndroidSdkLicenses import org.jetbrains.kotlin.gradle.BaseGradleIT.Companion.acceptAndroidSdkLicenses
import org.jetbrains.kotlin.gradle.model.ModelContainer import org.jetbrains.kotlin.gradle.model.ModelContainer
import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction
import org.jetbrains.kotlin.gradle.native.disableKotlinNativeCaches
import org.jetbrains.kotlin.gradle.report.BuildReportType import org.jetbrains.kotlin.gradle.report.BuildReportType
import org.jetbrains.kotlin.gradle.util.modify import org.jetbrains.kotlin.gradle.util.modify
import org.jetbrains.kotlin.konan.target.HostManager import org.jetbrains.kotlin.konan.target.HostManager
@@ -45,7 +44,7 @@ fun KGPBaseTest.project(
projectPathAdditionalSuffix: String = "", projectPathAdditionalSuffix: String = "",
buildJdk: File? = null, buildJdk: File? = null,
localRepoDir: Path? = null, localRepoDir: Path? = null,
test: TestProject.() -> Unit = {} test: TestProject.() -> Unit = {},
): TestProject { ): TestProject {
val projectPath = setupProjectFromTestResources( val projectPath = setupProjectFromTestResources(
projectName, projectName,
@@ -105,7 +104,7 @@ fun KGPBaseTest.nativeProject(
projectPathAdditionalSuffix: String = "", projectPathAdditionalSuffix: String = "",
buildJdk: File? = null, buildJdk: File? = null,
localRepoDir: Path? = null, localRepoDir: Path? = null,
test: TestProject.() -> Unit = {} test: TestProject.() -> Unit = {},
): TestProject { ): TestProject {
val project = project( val project = project(
projectName = projectName, projectName = projectName,
@@ -120,7 +119,6 @@ fun KGPBaseTest.nativeProject(
localRepoDir = localRepoDir, localRepoDir = localRepoDir,
) )
project.configureSingleNativeTarget() project.configureSingleNativeTarget()
project.disableKotlinNativeCaches()
project.test() project.test()
return project return project
} }
@@ -136,7 +134,7 @@ fun TestProject.build(
enableBuildCacheDebug: Boolean = false, enableBuildCacheDebug: Boolean = false,
enableBuildScan: Boolean = this.enableBuildScan, enableBuildScan: Boolean = this.enableBuildScan,
buildOptions: BuildOptions = this.buildOptions, buildOptions: BuildOptions = this.buildOptions,
assertions: BuildResult.() -> Unit = {} assertions: BuildResult.() -> Unit = {},
) { ) {
if (enableBuildScan) agreeToBuildScanService() if (enableBuildScan) agreeToBuildScanService()
@@ -171,7 +169,7 @@ fun TestProject.buildAndFail(
enableBuildCacheDebug: Boolean = false, enableBuildCacheDebug: Boolean = false,
enableBuildScan: Boolean = this.enableBuildScan, enableBuildScan: Boolean = this.enableBuildScan,
buildOptions: BuildOptions = this.buildOptions, buildOptions: BuildOptions = this.buildOptions,
assertions: BuildResult.() -> Unit = {} assertions: BuildResult.() -> Unit = {},
) { ) {
if (enableBuildScan) agreeToBuildScanService() if (enableBuildScan) agreeToBuildScanService()
@@ -203,7 +201,7 @@ private fun BuildResult.additionalAssertions(buildOptions: BuildOptions) {
} }
internal inline fun <reified T> TestProject.getModels( internal inline fun <reified T> TestProject.getModels(
crossinline assertions: ModelContainer<T>.() -> Unit crossinline assertions: ModelContainer<T>.() -> Unit,
) { ) {
val allBuildArguments = commonBuildSetup( val allBuildArguments = commonBuildSetup(
@@ -231,7 +229,7 @@ internal inline fun <reified T> TestProject.getModels(
} }
fun TestProject.enableLocalBuildCache( fun TestProject.enableLocalBuildCache(
buildCacheLocation: Path buildCacheLocation: Path,
) { ) {
// language=Groovy // language=Groovy
settingsGradle.append( settingsGradle.append(
@@ -247,7 +245,7 @@ fun TestProject.enableLocalBuildCache(
fun TestProject.enableStatisticReports( fun TestProject.enableStatisticReports(
type: BuildReportType, type: BuildReportType,
url: String? url: String?,
) { ) {
gradleProperties.append( gradleProperties.append(
"\nkotlin.build.report.output=${type.name}\n" "\nkotlin.build.report.output=${type.name}\n"
@@ -262,7 +260,7 @@ fun TestProject.enableStatisticReports(
open class GradleProject( open class GradleProject(
val projectName: String, val projectName: String,
val projectPath: Path val projectPath: Path,
) { ) {
val buildGradle: Path get() = projectPath.resolve("build.gradle") val buildGradle: Path get() = projectPath.resolve("build.gradle")
val buildGradleKts: Path get() = projectPath.resolve("build.gradle.kts") val buildGradleKts: Path get() = projectPath.resolve("build.gradle.kts")
@@ -273,27 +271,27 @@ open class GradleProject(
fun classesDir( fun classesDir(
sourceSet: String = "main", sourceSet: String = "main",
language: String = "kotlin" language: String = "kotlin",
): Path = projectPath.resolve("build/classes/$language/$sourceSet/") ): Path = projectPath.resolve("build/classes/$language/$sourceSet/")
fun kotlinClassesDir( fun kotlinClassesDir(
sourceSet: String = "main" sourceSet: String = "main",
): Path = classesDir(sourceSet, language = "kotlin") ): Path = classesDir(sourceSet, language = "kotlin")
fun javaClassesDir( fun javaClassesDir(
sourceSet: String = "main" sourceSet: String = "main",
): Path = classesDir(sourceSet, language = "java") ): Path = classesDir(sourceSet, language = "java")
fun kotlinSourcesDir( fun kotlinSourcesDir(
sourceSet: String = "main" sourceSet: String = "main",
): Path = projectPath.resolve("src/$sourceSet/kotlin") ): Path = projectPath.resolve("src/$sourceSet/kotlin")
fun javaSourcesDir( fun javaSourcesDir(
sourceSet: String = "main" sourceSet: String = "main",
): Path = projectPath.resolve("src/$sourceSet/java") ): Path = projectPath.resolve("src/$sourceSet/java")
fun relativeToProject( fun relativeToProject(
files: List<Path> files: List<Path>,
): List<Path> = files.map { projectPath.relativize(it) } ): List<Path> = files.map { projectPath.relativize(it) }
} }
@@ -314,7 +312,7 @@ class TestProject(
* A port to debug the Kotlin daemon at. * A port to debug the Kotlin daemon at.
* Note that we'll need to let the debugger start listening at this port first *before* the Kotlin daemon is launched. * Note that we'll need to let the debugger start listening at this port first *before* the Kotlin daemon is launched.
*/ */
val kotlinDaemonDebugPort: Int? = null val kotlinDaemonDebugPort: Int? = null,
) : GradleProject(projectName, projectPath) { ) : GradleProject(projectName, projectPath) {
fun subProject(name: String) = GradleProject(name, projectPath.resolve(name)) fun subProject(name: String) = GradleProject(name, projectPath.resolve(name))
@@ -350,7 +348,7 @@ class TestProject(
otherProjectName: String, otherProjectName: String,
pathPrefix: String, pathPrefix: String,
newSubmoduleName: String = otherProjectName, newSubmoduleName: String = otherProjectName,
isKts: Boolean = false isKts: Boolean = false,
) { ) {
val otherProjectPath = "$pathPrefix/$otherProjectName".testProjectPath val otherProjectPath = "$pathPrefix/$otherProjectName".testProjectPath
otherProjectPath.copyRecursively(projectPath.resolve(newSubmoduleName)) otherProjectPath.copyRecursively(projectPath.resolve(newSubmoduleName))
@@ -367,7 +365,7 @@ class TestProject(
fun includeOtherProjectAsIncludedBuild( fun includeOtherProjectAsIncludedBuild(
otherProjectName: String, otherProjectName: String,
pathPrefix: String pathPrefix: String,
) { ) {
val otherProjectPath = "$pathPrefix/$otherProjectName".testProjectPath val otherProjectPath = "$pathPrefix/$otherProjectName".testProjectPath
otherProjectPath.copyRecursively(projectPath.resolve(otherProjectName)) otherProjectPath.copyRecursively(projectPath.resolve(otherProjectName))
@@ -389,7 +387,7 @@ private fun commonBuildSetup(
enableBuildCacheDebug: Boolean, enableBuildCacheDebug: Boolean,
enableBuildScan: Boolean, enableBuildScan: Boolean,
gradleVersion: GradleVersion, gradleVersion: GradleVersion,
kotlinDaemonDebugPort: Int? = null kotlinDaemonDebugPort: Int? = null,
): List<String> { ): List<String> {
return buildOptions.toArguments(gradleVersion) + buildArguments + listOfNotNull( return buildOptions.toArguments(gradleVersion) + buildArguments + listOfNotNull(
"--full-stacktrace", "--full-stacktrace",
@@ -406,7 +404,7 @@ private fun commonBuildSetup(
private fun TestProject.withBuildSummary( private fun TestProject.withBuildSummary(
buildArguments: List<String>, buildArguments: List<String>,
run: () -> Unit run: () -> Unit,
) { ) {
try { try {
run() run()
@@ -624,8 +622,6 @@ private fun TestProject.configureLocalRepository(localRepoDir: Path) {
} }
} }
internal fun TestProject.disableKotlinNativeCaches() = gradleProperties.toFile().disableKotlinNativeCaches()
internal fun TestProject.enableStableConfigurationCachePreview() { internal fun TestProject.enableStableConfigurationCachePreview() {
val settingsFile = if (settingsGradleKts.exists()) { val settingsFile = if (settingsGradleKts.exists()) {
settingsGradleKts settingsGradleKts
@@ -1,11 +1,11 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
} }
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
maven("<LocalRepo>") maven("<localRepo>")
} }
kotlin { kotlin {
@@ -1,5 +1,5 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
id("maven-publish") id("maven-publish")
} }
@@ -18,7 +18,7 @@ kotlin {
publishing { publishing {
repositories { repositories {
maven { maven {
url = uri("<LocalRepo>") url = uri("<localRepo>")
} }
} }
} }
@@ -1,5 +1,5 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
id("maven-publish") id("maven-publish")
} }
@@ -18,7 +18,7 @@ kotlin {
publishing { publishing {
repositories { repositories {
maven { maven {
url = uri("<LocalRepo>") url = uri("<localRepo>")
} }
} }
} }
@@ -1,5 +1,5 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
id("maven-publish") id("maven-publish")
} }
@@ -9,7 +9,7 @@ version = "1.0"
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven("<LocalRepo>") maven("<localRepo>")
} }
kotlin { kotlin {
@@ -23,7 +23,7 @@ kotlin {
publishing { publishing {
repositories { repositories {
maven { maven {
url = uri("<LocalRepo>") url = uri("<localRepo>")
} }
} }
} }
@@ -1,5 +1,5 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
} }
repositories { repositories {
@@ -1,11 +1,11 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
} }
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
maven("<LocalRepo>") maven("<localRepo>")
} }
kotlin { kotlin {
@@ -1,5 +1,5 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
id("maven-publish") id("maven-publish")
} }
@@ -18,7 +18,7 @@ kotlin {
publishing { publishing {
repositories { repositories {
maven { maven {
url = uri("<LocalRepo>") url = uri("<localRepo>")
} }
} }
} }
@@ -1,5 +1,5 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
id("maven-publish") id("maven-publish")
} }
@@ -18,7 +18,7 @@ kotlin {
publishing { publishing {
repositories { repositories {
maven { maven {
url = uri("<LocalRepo>") url = uri("<localRepo>")
} }
} }
} }
@@ -1,5 +1,5 @@
plugins { plugins {
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>") id("org.jetbrains.kotlin.multiplatform")
id("maven-publish") id("maven-publish")
} }
@@ -9,7 +9,7 @@ version = "1.0"
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven("<LocalRepo>") maven("<localRepo>")
} }
kotlin { kotlin {
@@ -23,7 +23,7 @@ kotlin {
publishing { publishing {
repositories { repositories {
maven { maven {
url = uri("<LocalRepo>") url = uri("<localRepo>")
} }
} }
} }