diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index f4de414de06..704f61f7a0c 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -228,40 +228,6 @@ Task standaloneTest(String name, Closure configureClosure) { } } -/** - * Creates a task for a linking test. Configures runner and adds library and test build tasks. - */ -Task linkTest(String name, Closure configureClosure) { - return KotlinNativeTestKt.createTest(project, name, KonanLinkTest) { task -> - task.configure(configureClosure) - if (task.enabled) { - konanArtifacts { - def lib = "lib$name" - def targetName = target.name - // build a library from KonanLinkTest::lib property - library(lib, targets: [targetName]) { - srcFiles task.lib - baseDir "$testOutputLocal/$name" - extraOpts task.flags - extraOpts project.globalTestArgs.findAll { !it.contains("-Xpartial-linkage") } - } - UtilsKt.dependsOnKonanBuildingTask(task, lib, target) - - // Build an executable with library - program(name, targets: [targetName]) { - libraries { - klibFile file("$testOutputLocal/$name/$targetName/${lib}.klib") - } - baseDir "$testOutputLocal/$name" - srcFiles task.getSources() - extraOpts task.flags - extraOpts project.globalTestArgs - } - } - } - } -} - /** * Creates a task for a dynamic test. Configures runner and adds library and test build tasks. */ @@ -575,13 +541,6 @@ standaloneTest("link_default_libs") { UtilsKt.dependsOnPlatformLibs(it) } -linkTest("no_purge_for_dependencies") { - useGoldenData = true - source = "link/purge1/prog.kt" - lib = "link/purge1/lib.kt" - UtilsKt.dependsOnPlatformLibs(it) -} - standaloneTest("check_stacktrace_format_coresymbolication") { disabled = !PlatformInfo.supportsCoreSymbolication(project) || project.globalTestArgs.contains('-opt') flags = ['-g', '-Xbinary=sourceInfoType=coresymbolication'] @@ -1333,7 +1292,7 @@ Task interopTestBase(String name, boolean multiFile, boolean interop2ForMainOnly def lib = "lib$name" def hasIntermediateLib = task.lib != null if (hasIntermediateLib) { - // build a library from KonanLinkTest::lib property + // build a library from KonanInteropTest::lib property library(lib, targets: [targetName]) { libraries { artifact interopLib @@ -2693,9 +2652,6 @@ task buildKonanTests { t -> .withType(KonanStandaloneTest.class) .each { // add library and source files - if (it instanceof KonanLinkTest) { - excludeList += it.lib - } if (it.source != null) { excludeList += it.source } diff --git a/kotlin-native/backend.native/tests/link/purge1/lib.kt b/kotlin-native/backend.native/tests/link/purge1/lib.kt deleted file mode 100644 index 2d2811083fe..00000000000 --- a/kotlin-native/backend.native/tests/link/purge1/lib.kt +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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. - */ -@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) - -import kotlinx.cinterop.convert -import platform.posix.* - -fun foo() { - println("linked library") - val size: size_t = 17.convert() - val e = fabs(1.toDouble()) - println("and symbols from posix available: $size; $e") -} diff --git a/kotlin-native/backend.native/tests/link/purge1/prog.kt b/kotlin-native/backend.native/tests/link/purge1/prog.kt deleted file mode 100644 index 6780fec41bc..00000000000 --- a/kotlin-native/backend.native/tests/link/purge1/prog.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * 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. - */ - - -fun main(args: Array) { - foo() -} diff --git a/kotlin-native/backend.native/tests/link/purge1/prog.out b/kotlin-native/backend.native/tests/link/purge1/prog.out deleted file mode 100644 index 602c1f38930..00000000000 --- a/kotlin-native/backend.native/tests/link/purge1/prog.out +++ /dev/null @@ -1,2 +0,0 @@ -linked library -and symbols from posix available: 17; 1.0 diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt index 1ef4d95cd0b..75a0cd46646 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt @@ -429,11 +429,6 @@ open class KonanInteropTest : KonanStandaloneTest() { var lib: String? = null } -open class KonanLinkTest : KonanStandaloneTest() { - @Input - lateinit var lib: String -} - /** * Test task to check a library built by `-produce dynamic`. * C source code should contain `testlib` as a reference to a testing library. diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt index 1c048d6510c..a4c974395f7 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/Utils.kt @@ -86,11 +86,6 @@ fun Task.dependsOnPlatformLibs() { this.dependsOn(":kotlin-native:platformLibs:${project.testTarget.name}-$it") //this.dependsOn(":kotlin-native:platformLibs:${project.testTarget.name}-${it}Cache") } - if (this is KonanLinkTest) { - project.file(lib).dependencies().forEach { - this.dependsOn(":kotlin-native:platformLibs:${project.testTarget.name}-$it") - } - } this.dependsOnDist() } ?: error("unsupported task : $this") } diff --git a/native/native.tests/testData/codegen/link/noPurgeForDependencies.kt b/native/native.tests/testData/codegen/link/noPurgeForDependencies.kt new file mode 100644 index 00000000000..6e44375ec97 --- /dev/null +++ b/native/native.tests/testData/codegen/link/noPurgeForDependencies.kt @@ -0,0 +1,23 @@ +// MODULE: lib +// FILE: lib.kt + +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) + +import kotlinx.cinterop.convert +import platform.posix.* + +fun foo(): String { + val size: size_t = 17.convert() + val e = fabs(1.toDouble()) + return "$size; $e" +} + +// MODULE: main(lib) +// FILE: main.kt + +import kotlin.test.* + +fun box(): String { + assertEquals("17; 1.0", foo()) + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java index fdbbbb89e84..1789df6c287 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java @@ -3221,6 +3221,12 @@ public class FirNativeCodegenLocalTestGenerated extends AbstractNativeCodegenBox runTest("native/native.tests/testData/codegen/link/link.kt"); } + @Test + @TestMetadata("noPurgeForDependencies.kt") + public void testNoPurgeForDependencies() throws Exception { + runTest("native/native.tests/testData/codegen/link/noPurgeForDependencies.kt"); + } + @Test @TestMetadata("omitUnused.kt") public void testOmitUnused() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java index 787cda33e66..de288814a18 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java @@ -3147,6 +3147,12 @@ public class NativeCodegenLocalTestGenerated extends AbstractNativeCodegenBoxTes runTest("native/native.tests/testData/codegen/link/link.kt"); } + @Test + @TestMetadata("noPurgeForDependencies.kt") + public void testNoPurgeForDependencies() throws Exception { + runTest("native/native.tests/testData/codegen/link/noPurgeForDependencies.kt"); + } + @Test @TestMetadata("omitUnused.kt") public void testOmitUnused() throws Exception { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt index 14db7c23cc5..54cabb43dcb 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt @@ -303,6 +303,7 @@ private class ExtTestDataFile( || importedFqName.startsWith(KOTLINX_PACKAGE_NAME) || importedFqName.startsWith(HELPERS_PACKAGE_NAME) || importedFqName.startsWith(CNAMES_PACKAGE_NAME) + || importedFqName.startsWith(PLATFORM_PACKAGE_NAME) ) { return } @@ -596,6 +597,7 @@ private class ExtTestDataFile( private val HELPERS_PACKAGE_NAME = Name.identifier("helpers") private val KOTLINX_PACKAGE_NAME = Name.identifier("kotlinx") private val CNAMES_PACKAGE_NAME = Name.identifier("cnames") + private val PLATFORM_PACKAGE_NAME = Name.identifier("platform") private val MANDATORY_SOURCE_TRANSFORMERS: ExternalSourceTransformers = listOf(DiagnosticsRemovingSourceTransformer) }