From 9c32a66e9cdd1b3d7bfae2aeb0c1ee55ab090d1d Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Mon, 17 Apr 2023 13:22:25 +0000 Subject: [PATCH] migrated NativeExternalDependenciesIT to gradle TestKit --- .../native/NativeExternalDependenciesIT.kt | 114 ++++++++---------- .../gradle/native/NativeIrLinkerIssuesIT.kt | 56 ++++----- .../gradle/testbase/nativeTestHelpers.kt | 12 ++ .../gradle/testbase/outputAssertions.kt | 16 ++- .../build.gradle.kts | 3 +- .../app/build.gradle.kts | 1 - .../build.gradle.kts | 1 - .../app/build.gradle.kts | 1 - 8 files changed, 104 insertions(+), 100 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/nativeTestHelpers.kt diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeExternalDependenciesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeExternalDependenciesIT.kt index 82240d47467..4f3593a8a07 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeExternalDependenciesIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeExternalDependenciesIT.kt @@ -1,37 +1,45 @@ /* - * 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. */ package org.jetbrains.kotlin.gradle.native -import org.jetbrains.kotlin.gradle.BaseGradleIT -import org.jetbrains.kotlin.gradle.GradleVersionRequired -import org.jetbrains.kotlin.konan.target.HostManager -import org.jetbrains.kotlin.konan.target.KonanTarget -import org.junit.Assume.assumeFalse -import org.junit.Test +import org.gradle.util.GradleVersion +import org.jetbrains.kotlin.gradle.testbase.* +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.condition.DisabledOnOs +import org.junit.jupiter.api.condition.OS import java.io.File import java.util.* +import kotlin.io.path.appendText import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull -class NativeExternalDependenciesIT : BaseGradleIT() { - override val defaultGradleVersion: GradleVersionRequired - get() = GradleVersionRequired.FOR_MPP_SUPPORT +@DisplayName("Tests for K/N builds with external dependencies") +@NativeGradlePluginTests +internal class NativeExternalDependenciesIT : KGPBaseTest() { - @Test - fun `no external dependencies`() = buildProjectWithDependencies { externalDependenciesText -> - assertNull(externalDependenciesText) + @DisplayName("K/N shouldn't contain any external dependencies by default") + @GradleTest + fun shouldNotUseExternalDependencies(gradleVersion: GradleVersion) { + buildProjectWithDependencies(gradleVersion) { externalDependenciesText -> + assertNull(externalDependenciesText) + } } - @Test - fun `ktor 1_5_4 and coroutines 1_5_0-RC-native-mt`() { - // These versions of Ktor and coroutines don't support macos-arm64 - assumeFalse(hostIsMacArm64()) + @DisplayName("Should build with ktor 1.5.4 and coroutines 1.5.0-RC-native-mt") + @GradleTest + @DisabledOnOs( + value = [OS.MAC], + architectures = ["aarch64"], + disabledReason = "These versions of Ktor and coroutines don't support macos-arm64" + ) + fun shouldUseOldKtorAndCoroutinesExternalDependencies(gradleVersion: GradleVersion) { buildProjectWithDependencies( + gradleVersion, "io.ktor:ktor-io:1.5.4", "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-RC-native-mt" ) { externalDependenciesText -> @@ -40,14 +48,14 @@ class NativeExternalDependenciesIT : BaseGradleIT() { assertEquals( """ |0 native-external-dependencies - |1 io.ktor:ktor-io,io.ktor:ktor-io-$MASKED_TARGET_NAME[1.5.4] #0[1.5.4] + |1 io.ktor:ktor-io,io.ktor:ktor-io-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[1.5.4] #0[1.5.4] |${'\t'}/some/path/ktor-io.klib |${'\t'}/some/path/ktor-io-cinterop-bits.klib |${'\t'}/some/path/ktor-io-cinterop-sockets.klib - |2 org.jetbrains.kotlinx:atomicfu,org.jetbrains.kotlinx:atomicfu-$MASKED_TARGET_NAME[0.16.1] #3[0.16.1] #1[0.15.1] + |2 org.jetbrains.kotlinx:atomicfu,org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[0.16.1] #3[0.16.1] #1[0.15.1] |${'\t'}/some/path/atomicfu.klib |${'\t'}/some/path/atomicfu-cinterop-interop.klib - |3 org.jetbrains.kotlinx:kotlinx-coroutines-core,org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME[1.5.0-RC-native-mt] #0[1.5.0-RC-native-mt] #1[1.4.3-native-mt] + |3 org.jetbrains.kotlinx:kotlinx-coroutines-core,org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[1.5.0-RC-native-mt] #0[1.5.0-RC-native-mt] #1[1.4.3-native-mt] |${'\t'}/some/path/kotlinx-coroutines-core.klib | """.trimMargin(), @@ -56,37 +64,42 @@ class NativeExternalDependenciesIT : BaseGradleIT() { } } - @Test - fun `ktor 1_6_5 and coroutines 1_5_2-native-mt`() = buildProjectWithDependencies( - "io.ktor:ktor-io:1.6.5", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt" - ) { externalDependenciesText -> - assertNotNull(externalDependenciesText) + @DisplayName("Should build with ktor 1.6.5 and coroutines 1.5.2-native-mt") + @GradleTest + fun shouldUseKtorAndCoroutinesExternalDependencies(gradleVersion: GradleVersion) { + buildProjectWithDependencies( + gradleVersion, + "io.ktor:ktor-io:1.6.5", + "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt" + ) { externalDependenciesText -> + assertNotNull(externalDependenciesText) - assertEquals( - """ + assertEquals( + """ |0 native-external-dependencies - |1 io.ktor:ktor-io,io.ktor:ktor-io-$MASKED_TARGET_NAME[1.6.5] #0[1.6.5] + |1 io.ktor:ktor-io,io.ktor:ktor-io-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[1.6.5] #0[1.6.5] |${'\t'}/some/path/ktor-io.klib |${'\t'}/some/path/ktor-io-cinterop-bits.klib |${'\t'}/some/path/ktor-io-cinterop-sockets.klib - |2 org.jetbrains.kotlinx:atomicfu,org.jetbrains.kotlinx:atomicfu-$MASKED_TARGET_NAME[0.16.3] #3[0.16.3] #1[0.16.3] + |2 org.jetbrains.kotlinx:atomicfu,org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[0.16.3] #3[0.16.3] #1[0.16.3] |${'\t'}/some/path/atomicfu.klib |${'\t'}/some/path/atomicfu-cinterop-interop.klib - |3 org.jetbrains.kotlinx:kotlinx-coroutines-core,org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME[1.5.2-native-mt] #0[1.5.2-native-mt] #1[1.5.2-native-mt] + |3 org.jetbrains.kotlinx:kotlinx-coroutines-core,org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[1.5.2-native-mt] #0[1.5.2-native-mt] #1[1.5.2-native-mt] |${'\t'}/some/path/kotlinx-coroutines-core.klib | """.trimMargin(), - externalDependenciesText - ) + externalDependenciesText + ) + } } private fun buildProjectWithDependencies( + gradleVersion: GradleVersion, vararg dependencies: String, externalDependenciesTextConsumer: (externalDependenciesText: String?) -> Unit ) { - with(transformNativeTestProjectWithPluginDsl("native-external-dependencies")) { - gradleBuildScript().appendText( + nativeProject("native-external-dependencies", gradleVersion) { + buildGradleKts.appendText( """ | |kotlin { @@ -98,27 +111,15 @@ class NativeExternalDependenciesIT : BaseGradleIT() { """.trimMargin() ) - build( - "buildExternalDependenciesFile" - ) { - assertSuccessful() + build("buildExternalDependenciesFile") { assertTasksExecuted(":buildExternalDependenciesFile") - val kotlinNativeTargetName = findKotlinNativeTargetName(output) - assertNotNull(kotlinNativeTargetName) val externalDependenciesFile = findParameterInOutput("for_test_external_dependencies_file", output)?.let(::File) val externalDependenciesText = if (externalDependenciesFile?.exists() == true) { externalDependenciesFile.readText() .lineSequence() .map { line -> - if (line.firstOrNull()?.isWhitespace() == true) { - // Transform artifact path. - val pureFileName = File(line.trimStart()).name - "\t/some/path/$pureFileName" - } else { - // Transform module name (mask target name). - line.replace(kotlinNativeTargetName, MASKED_TARGET_NAME) - } + if (line.firstOrNull()?.isWhitespace() == true) "\t/some/path/${File(line.trimStart()).name}" else line } .joinToString("\n") } else null @@ -128,19 +129,4 @@ class NativeExternalDependenciesIT : BaseGradleIT() { } } - internal companion object { - val MASKED_TARGET_NAME = "testTarget" + HostManager.host.architecture.name - - fun hostIsMacArm64() = HostManager.host == KonanTarget.MACOS_ARM64 - - fun findParameterInOutput(name: String, output: String): String? = - output.lineSequence().mapNotNull { line -> - val (key, value) = line.split('=', limit = 2).takeIf { it.size == 2 } ?: return@mapNotNull null - if (key.endsWith(name)) value else null - }.firstOrNull() - - fun findKotlinNativeTargetName(output: String): String? = findParameterInOutput("for_test_kotlin_native_target", output) - ?.takeIf(String::isNotBlank) - ?.lowercase(Locale.getDefault()) - } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeIrLinkerIssuesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeIrLinkerIssuesIT.kt index 9eaff86f865..b38f8a5f790 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeIrLinkerIssuesIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeIrLinkerIssuesIT.kt @@ -7,9 +7,8 @@ package org.jetbrains.kotlin.gradle.native import org.jetbrains.kotlin.gradle.BaseGradleIT import org.jetbrains.kotlin.gradle.GradleVersionRequired -import org.jetbrains.kotlin.gradle.native.NativeExternalDependenciesIT.Companion.MASKED_TARGET_NAME -import org.jetbrains.kotlin.gradle.native.NativeExternalDependenciesIT.Companion.findKotlinNativeTargetName -import org.jetbrains.kotlin.gradle.native.NativeExternalDependenciesIT.Companion.findParameterInOutput +import org.jetbrains.kotlin.gradle.testbase.DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX +import org.jetbrains.kotlin.gradle.testbase.findParameterInOutput import org.jetbrains.kotlin.konan.library.KONAN_PLATFORM_LIBS_NAME_PREFIX import org.jetbrains.kotlin.konan.target.HostManager import org.jetbrains.kotlin.konan.target.KonanTarget @@ -49,18 +48,18 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() { | |This could happen if there are two libraries, where one library was compiled against the different version of the other library than the one currently used in the project. Please check that the project configuration is correct and has consistent versions of dependencies. | - |The list of libraries that depend on "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME)" and may lead to conflicts: - |1. "io.ktor:ktor-client-core (io.ktor:ktor-client-core-$MASKED_TARGET_NAME): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.5.0-RC-native-mt" is used in the project) - |2. "io.ktor:ktor-http (io.ktor:ktor-http-$MASKED_TARGET_NAME): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.5.0-RC-native-mt" is used in the project) - |3. "io.ktor:ktor-http-cio (io.ktor:ktor-http-cio-$MASKED_TARGET_NAME): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.5.0-RC-native-mt" is used in the project) - |4. "io.ktor:ktor-io (io.ktor:ktor-io-$MASKED_TARGET_NAME): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.5.0-RC-native-mt" is used in the project) - |5. "io.ktor:ktor-utils (io.ktor:ktor-utils-$MASKED_TARGET_NAME): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.5.0-RC-native-mt" is used in the project) + |The list of libraries that depend on "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX)" and may lead to conflicts: + |1. "io.ktor:ktor-client-core (io.ktor:ktor-client-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.0-RC-native-mt" is used in the project) + |2. "io.ktor:ktor-http (io.ktor:ktor-http-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.0-RC-native-mt" is used in the project) + |3. "io.ktor:ktor-http-cio (io.ktor:ktor-http-cio-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.0-RC-native-mt" is used in the project) + |4. "io.ktor:ktor-io (io.ktor:ktor-io-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.0-RC-native-mt" is used in the project) + |5. "io.ktor:ktor-utils (io.ktor:ktor-utils-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4" (was compiled against "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt" but "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.0-RC-native-mt" is used in the project) | |Project dependencies: - |+--- io.ktor:ktor-client-core (io.ktor:ktor-client-core-$MASKED_TARGET_NAME): 1.5.4 - || +--- io.ktor:ktor-http (io.ktor:ktor-http-$MASKED_TARGET_NAME): 1.5.4 - || | +--- io.ktor:ktor-utils (io.ktor:ktor-utils-$MASKED_TARGET_NAME): 1.5.4 - || | | +--- io.ktor:ktor-io (io.ktor:ktor-io-$MASKED_TARGET_NAME): 1.5.4 + |+--- io.ktor:ktor-client-core (io.ktor:ktor-client-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4 + || +--- io.ktor:ktor-http (io.ktor:ktor-http-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4 + || | +--- io.ktor:ktor-utils (io.ktor:ktor-utils-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4 + || | | +--- io.ktor:ktor-io (io.ktor:ktor-io-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4 || | | | +--- io.ktor:ktor-io-cinterop-bits: 1.5.4 || | | | | \--- stdlib: 1.4.32 -> $kotlinNativeCompilerVersion || | | | +--- io.ktor:ktor-io-cinterop-sockets: 1.5.4 @@ -80,36 +79,36 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() { || | | | | +--- stdlib: $kotlinNativeCompilerVersion || | | | | \--- org.jetbrains.kotlin.native.platform.posix: $kotlinNativeCompilerVersion (*) || | | | +--- org.jetbrains.kotlin.native.platform.posix: 1.4.32 -> $kotlinNativeCompilerVersion (*) - || | | | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$MASKED_TARGET_NAME): 0.15.1 -> 0.16.1 + || | | | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 0.15.1 -> 0.16.1 || | | | | +--- stdlib: 1.5 -> $kotlinNativeCompilerVersion || | | | | +--- org.jetbrains.kotlin.native.platform.posix: 1.5 -> $kotlinNativeCompilerVersion (*) || | | | | \--- org.jetbrains.kotlinx:atomicfu-cinterop-interop: 0.16.1 || | | | | +--- stdlib: 1.5 -> $kotlinNativeCompilerVersion || | | | | \--- org.jetbrains.kotlin.native.platform.posix: 1.5 -> $kotlinNativeCompilerVersion (*) || | | | +--- org.jetbrains.kotlinx:atomicfu-cinterop-interop: 0.16.1 (*) - || | | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt -> 1.5.0-RC-native-mt + || | | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt -> 1.5.0-RC-native-mt || | | | ^^^ This module contains symbol kotlinx.coroutines/CancellationException|null[0] that is the cause of the conflict. || | | | +--- stdlib: 1.5 -> $kotlinNativeCompilerVersion || | | | +--- org.jetbrains.kotlin.native.platform.CoreFoundation: 1.5 -> $kotlinNativeCompilerVersion (*) || | | | +--- org.jetbrains.kotlin.native.platform.darwin: 1.5 -> $kotlinNativeCompilerVersion (*) || | | | +--- org.jetbrains.kotlin.native.platform.posix: 1.5 -> $kotlinNativeCompilerVersion (*) - || | | | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$MASKED_TARGET_NAME): 0.16.1 (*) + || | | | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 0.16.1 (*) || | | | \--- org.jetbrains.kotlinx:atomicfu-cinterop-interop: 0.16.1 (*) - || | | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$MASKED_TARGET_NAME): 0.15.1 -> 0.16.1 (*) - || | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt -> 1.5.0-RC-native-mt (*) + || | | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 0.15.1 -> 0.16.1 (*) + || | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt -> 1.5.0-RC-native-mt (*) || | | ^^^ This module contains symbol kotlinx.coroutines/CancellationException|null[0] that is the cause of the conflict. - || | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$MASKED_TARGET_NAME): 0.15.1 -> 0.16.1 (*) - || | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt -> 1.5.0-RC-native-mt (*) + || | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 0.15.1 -> 0.16.1 (*) + || | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt -> 1.5.0-RC-native-mt (*) || | ^^^ This module contains symbol kotlinx.coroutines/CancellationException|null[0] that is the cause of the conflict. - || +--- io.ktor:ktor-http-cio (io.ktor:ktor-http-cio-$MASKED_TARGET_NAME): 1.5.4 - || | +--- io.ktor:ktor-http (io.ktor:ktor-http-$MASKED_TARGET_NAME): 1.5.4 (*) - || | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$MASKED_TARGET_NAME): 0.15.1 -> 0.16.1 (*) - || | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt -> 1.5.0-RC-native-mt (*) + || +--- io.ktor:ktor-http-cio (io.ktor:ktor-http-cio-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4 + || | +--- io.ktor:ktor-http (io.ktor:ktor-http-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.4 (*) + || | +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 0.15.1 -> 0.16.1 (*) + || | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt -> 1.5.0-RC-native-mt (*) || | ^^^ This module contains symbol kotlinx.coroutines/CancellationException|null[0] that is the cause of the conflict. - || +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$MASKED_TARGET_NAME): 0.15.1 -> 0.16.1 (*) - || \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.4.3-native-mt -> 1.5.0-RC-native-mt (*) + || +--- org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 0.15.1 -> 0.16.1 (*) + || \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.4.3-native-mt -> 1.5.0-RC-native-mt (*) || ^^^ This module contains symbol kotlinx.coroutines/CancellationException|null[0] that is the cause of the conflict. - |\--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$MASKED_TARGET_NAME): 1.5.0-RC-native-mt (*) + |\--- org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX): 1.5.0-RC-native-mt (*) | ^^^ This module contains symbol kotlinx.coroutines/CancellationException|null[0] that is the cause of the conflict. | |(*) - dependencies omitted (listed previously) @@ -272,8 +271,6 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() { build("linkDebugExecutableNative") { assertFailed() - val kotlinNativeTargetName = findKotlinNativeTargetName(output) - assertNotNull(kotlinNativeTargetName) val kotlinNativeCompilerVersion = findKotlinNativeCompilerVersion(output) assertNotNull(kotlinNativeCompilerVersion) @@ -281,7 +278,6 @@ class NativeIrLinkerIssuesIT : BaseGradleIT() { val errorMessage = ERROR_LINE_REGEX.findAll(getOutputForTask("linkDebugExecutableNative")) .map { matchResult -> matchResult.groupValues[1] } .filterNot { it.startsWith("w:") || it.startsWith("v:") || it.startsWith("i:") } - .map { line -> line.replace(kotlinNativeTargetName, MASKED_TARGET_NAME) } .map { line -> line.replace(COMPRESSED_PLATFORM_LIBS_REGEX) { result -> val rangeWithPlatformLibrariesCount = result.groups[1]!!.range diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/nativeTestHelpers.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/nativeTestHelpers.kt new file mode 100644 index 00000000000..638adf5f602 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/nativeTestHelpers.kt @@ -0,0 +1,12 @@ +/* + * 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. + */ + +package org.jetbrains.kotlin.gradle.testbase + +import org.jetbrains.kotlin.konan.target.HostManager +import org.jetbrains.kotlin.konan.target.presetName +import java.util.* + +val DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX = HostManager.host.presetName.lowercase(Locale.getDefault()) \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/outputAssertions.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/outputAssertions.kt index c27bff6a655..4e055f8b9bb 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/outputAssertions.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/outputAssertions.kt @@ -214,4 +214,18 @@ fun BuildResult.assertDeprecationWarningsArePresent(warningMode: WarningMode) { "[GradleWarningsDetectorPlugin] Some deprecation warnings were found during this build.", getWarningModeChangeAdvice(warningMode) ) -} \ No newline at end of file +} + +/** + * This function searches for a given parameter in a multi-line output string and returns its value. + * + * The output string is assumed to be in the form of key-value pairs separated by an equal sign (‘=’) on each line. + * + * If the specified parameter name is found at the end of a key, the corresponding value is returned. + * If the parameter is not found, the function returns null. + */ +fun findParameterInOutput(name: String, output: String): String? = + output.lineSequence().mapNotNull { line -> + val (key, value) = line.split('=', limit = 2).takeIf { it.size == 2 } ?: return@mapNotNull null + if (key.endsWith(name)) value else null + }.firstOrNull() \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-external-dependencies/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-external-dependencies/build.gradle.kts index 8a16078ae01..f0c5e8002bb 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-external-dependencies/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-external-dependencies/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.jetbrains.kotlin.multiplatform").version("") + id("org.jetbrains.kotlin.multiplatform") } repositories { @@ -24,7 +24,6 @@ val buildExternalDependenciesFile = tasks.register("buildExternalDependenciesFil .invoke(null, project) ?.toString().orEmpty() - println("for_test_kotlin_native_target=") println("for_test_external_dependencies_file=$externalDependenciesFile") } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-gone-declaration/app/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-gone-declaration/app/build.gradle.kts index bf1d279b720..c00eeaf48cb 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-gone-declaration/app/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-gone-declaration/app/build.gradle.kts @@ -26,5 +26,4 @@ val konanHome: String? by ext.properties val kotlinNativeCompilerVersion = konanHome?.let { org.jetbrains.kotlin.konan.target.Distribution(it).compilerVersion } ?: "" -println("for_test_kotlin_native_target=") println("for_test_kotlin_native_compiler_version=$kotlinNativeCompilerVersion") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-ktor-and-coroutines/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-ktor-and-coroutines/build.gradle.kts index 826be53ab2e..a07408a4564 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-ktor-and-coroutines/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-ktor-and-coroutines/build.gradle.kts @@ -25,5 +25,4 @@ val konanHome: String? by ext.properties val kotlinNativeCompilerVersion = konanHome?.let { org.jetbrains.kotlin.konan.target.Distribution(it).compilerVersion } ?: "" -println("for_test_kotlin_native_target=") println("for_test_kotlin_native_compiler_version=$kotlinNativeCompilerVersion") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-symbol-mismatch/app/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-symbol-mismatch/app/build.gradle.kts index eb09de0b04a..91b7c814c7a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-symbol-mismatch/app/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-ir-linker-issues-symbol-mismatch/app/build.gradle.kts @@ -26,5 +26,4 @@ val konanHome: String? by ext.properties val kotlinNativeCompilerVersion = konanHome?.let { org.jetbrains.kotlin.konan.target.Distribution(it).compilerVersion } ?: "" -println("for_test_kotlin_native_target=") println("for_test_kotlin_native_compiler_version=$kotlinNativeCompilerVersion")