diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 2cd06fcb384..b4eb5d83dfc 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -1087,11 +1087,6 @@ if (PlatformInfo.isAppleTarget(project)) { it.extraOpts '-Xforeign-exception-mode', "objc-wrap" } - createInterop("objcGh3343") { - it.defFile 'framework/gh3343/objclib.def' - it.headers "$projectDir/framework/gh3343/objclib.h" - it.linkerOpts "-lobjcgh3343" - } createInterop("objcKt43517") { it.defFile 'framework/kt43517/kt43517.def' } @@ -1877,356 +1872,6 @@ Task frameworkTest(String name, Closure configurator) { } } -Task objcExportTest( - Task allTask, - String suffix, - List frameworkOpts, - List swiftOpts, - Boolean isStaticFramework, - Boolean needLazyHeaderCheck -) { - needLazyHeaderCheck = needLazyHeaderCheck && !PlatformInfo.isK2(project) // generating lazy headers is NYI in K2 - final String name = "testObjCExport$suffix" - final String frameworkName = "Kt$suffix" - final String expectedLazyHeaderName = "expectedLazy${suffix}.h" - final Task task = frameworkTest(name) { - final String dir = "$testOutputFramework/$name" - final File lazyHeader = file("$dir/$target-lazy.h") - lazyHeader.delete() // Clean up after previous runs - - doLast { - // Check lazy header. - if (needLazyHeaderCheck) { - final String expectedLazyHeaderDir = file("objcexport/") - final File expectedLazyHeader = new File(expectedLazyHeaderDir, expectedLazyHeaderName) - - if (!expectedLazyHeader.exists() || expectedLazyHeader.readLines() != lazyHeader.readLines()) { - exec { - commandLine 'diff', '-u', expectedLazyHeader, lazyHeader - ignoreExitValue = true - } - - copy { - from(lazyHeader) - into(expectedLazyHeaderDir) - rename { expectedLazyHeaderName } - } - - throw new Error("$expectedLazyHeader file patched;\nRun gradlew ${allTask.path} --continue and don't forget to commit the patch") - } - } - - // Check bundle ID. - final String frameworkPath = "$dir/$target/Kt.framework" - final Pattern pattern = ~"CFBundleIdentifier\n\\s*foo.bar" - final String plistPath = (target.family == Family.OSX) ? - "$frameworkPath/Resources/Info.plist" : - "$frameworkPath/Info.plist" - final String plistContent = file(plistPath).text - if (!pattern.matcher(plistContent).find()) { - throw new Error("Unexpected Info.plist content:\n$plistContent") - } - } - - def libraryName = frameworkName + "Library" - def noEnumEntriesLibraryName = frameworkName + "NoEnumEntriesLibrary" - File exportedKlibArtifact = null - konanArtifacts { - library(libraryName, targets: [target.name]) { - srcDir "objcexport/library" - artifactName "test-$libraryName" - delegate.getByTarget(target.name).configure{ - UtilsKt.dependsOnDist(it) - } - - extraOpts "-Xshort-module-name=MyLibrary" - extraOpts "-module-name", "org.jetbrains.kotlin.native.test-library" - } - library(noEnumEntriesLibraryName, targets: [target.name]) { - srcDir "objcexport/noEnumEntries" - artifactName "test-no-enum-entries-$libraryName" - delegate.getByTarget(target.name).configure{ - UtilsKt.dependsOnDist(it) - } - - exportedKlibArtifact = getArtifactByTarget(target.name) - extraOpts "-Xshort-module-name=NoEnumEntriesLibrary" - extraOpts "-module-name", "org.jetbrains.kotlin.native.test-no-enum-entries-library" - extraOpts "-XXLanguage:-EnumEntries" - } - } - codesign = !isStaticFramework - framework(frameworkName) { - sources = ['objcexport'] - libraries = [libraryName, noEnumEntriesLibraryName] - artifact = 'Kt' - isStatic = isStaticFramework - if (needLazyHeaderCheck) { - opts += "-Xemit-lazy-objc-header=$lazyHeader" - } - opts += [ - "-Xexport-kdoc", - "-Xbinary=bundleId=foo.bar", - "-Xexport-library=$exportedKlibArtifact", - "-module-name", "Kt" - ] - opts += frameworkOpts - } - swiftSources = ['objcexport'] - swiftExtraOpts = swiftOpts - if (isNoopGC) { - swiftExtraOpts += ["-D", "NOOP_GC"] - } - if (isAggressiveGC) { - swiftExtraOpts += ["-D", "AGGRESSIVE_GC"] - } - } - allTask.dependsOn(task) - return task -} - - - -if (PlatformInfo.isAppleTarget(project)) { - final Task ObjCExportAllTask = tasks.create("testObjCExportAll") - objcExportTest( - ObjCExportAllTask, - '', - [], - [], - false, - true - ) - objcExportTest( - ObjCExportAllTask, - 'NoGenerics', - ["-Xno-objc-generics"], - [ '-D', 'NO_GENERICS' ], - false, - true - ) - objcExportTest( - ObjCExportAllTask, - 'LegacySuspendUnit', - ["-Xbinary=unitSuspendFunctionObjCExport=legacy"], - [ '-D', 'LEGACY_SUSPEND_UNIT_FUNCTION_EXPORT' ], - false, - true - ) - objcExportTest( - ObjCExportAllTask, - 'NoSwiftMemberNameMangling', - ["-Xbinary=objcExportDisableSwiftMemberNameMangling=true"], - [ '-D', 'DISABLE_MEMBER_NAME_MANGLING' ], - false, - false - ) - objcExportTest( - ObjCExportAllTask, - 'NoInterfaceMemberNameMangling', - ["-Xbinary=objcExportIgnoreInterfaceMethodCollisions=true"], - [ '-D', 'DISABLE_INTERFACE_METHOD_NAME_MANGLING' ], - false, - false - ) - - objcExportTest( - ObjCExportAllTask, - 'Static', - ["-Xbinary=objcExportSuspendFunctionLaunchThreadRestriction=none"], - [ '-D', 'ALLOW_SUSPEND_ANY_THREAD' ], - true, - false - ) - - - frameworkTest('testValuesGenericsFramework') { - framework('ValuesGenerics') { - sources = ['objcexport/values.kt', 'framework/values_generics'] - } - swiftSources = ['framework/values_generics/'] - } - - frameworkTest("testStdlibFramework") { - framework('Stdlib') { - sources = ['framework/stdlib'] - } - swiftSources = ['framework/stdlib/'] - } - - if (cacheTesting != null && cacheTesting.isDynamic) { - // testMultipleFrameworks disabled until https://youtrack.jetbrains.com/issue/KT-34262 is fixed. - } else frameworkTest("testMultipleFrameworks") { - framework('First') { - sources = ['framework/multiple/framework1', 'framework/multiple/shared'] - } - framework('Second') { - sources = ['framework/multiple/framework2', 'framework/multiple/shared'] - } - swiftSources = ['framework/multiple'] - } - - frameworkTest("testMultipleFrameworksStatic") { - // this test doesn't work with caches. - if (cacheTesting != null && !runtimeAssertionsPanic) { - // See https://youtrack.jetbrains.com/issue/KT-34261. - expectedExitStatus = 134 - } - - framework('FirstStatic') { - artifact = 'First' - sources = ['framework/multiple/framework1', 'framework/multiple/shared'] - isStatic = true - opts = ['-Xstatic-framework', "-Xpre-link-caches=enable"] - } - framework('SecondStatic') { - artifact = 'Second' - sources = ['framework/multiple/framework2', 'framework/multiple/shared'] - isStatic = true - opts = ['-Xstatic-framework', "-Xpre-link-caches=enable"] - } - codesign = false - swiftSources = ['framework/multiple'] - } - - frameworkTest("testGh3343Framework") { - framework('Gh3343') { - sources = ['framework/gh3343'] - libraries = ['objcGh3343'] - } - swiftSources = ['framework/gh3343/'] - } - - frameworkTest("testKt42397Framework") { - enabled = !project.globalTestArgs.contains('-opt') - framework("Kt42397") { - sources = ['framework/kt42397'] - } - swiftSources = ['framework/kt42397'] - } - - frameworkTest("testKt43517Framework") { - framework('Kt43517') { - sources = ['framework/kt43517'] - libraries = ['objcKt43517'] - } - swiftSources = ['framework/kt43517/'] - } - - frameworkTest("testStackTraceFramework") { - enabled = !project.globalTestArgs.contains('-opt') - framework('Stacktrace') { - sources = ['framework/stacktrace'] - opts = ['-g'] - } - swiftSources = ['framework/stacktrace/'] - } - - frameworkTest("testStackTraceBridgesFramework") { - enabled = !project.globalTestArgs.contains('-opt') - framework('StacktraceBridges') { - sources = ['framework/stacktraceBridges'] - opts = ['-g'] - } - swiftSources = ['framework/stacktraceBridges/'] - } - - - frameworkTest("testStackTraceByLibbacktraceFramework") { - enabled = !project.globalTestArgs.contains('-opt') - framework('StacktraceByLibbacktrace') { - sources = ['framework/stacktraceByLibbacktrace'] - opts = ['-g', '-Xbinary=sourceInfoType=libbacktrace'] - } - swiftSources = ['framework/stacktraceByLibbacktrace/'] - } - - frameworkTest("testAbstractInstantiationFramework") { - framework('AbstractInstantiation') { - sources = ['framework/abstractInstantiation'] - } - swiftSources = ['framework/abstractInstantiation/'] - expectedExitStatus = 134 - } - - frameworkTest("testFrameworkBundleId") { - def currentTarget = project.target.name - enabled = currentTarget.startsWith("mac") - - framework("Foo") { - sources = ["framework/bundle_id/main.kt", "framework/bundle_id/lib.kt"] - opts = ["-Xbinary=bundleVersion=FooBundleVersion", "-Xbinary=bundleShortVersionString=FooBundleShortVersionString"] - } - swiftSources = [] - - doLast { - def frameworkPath = "$testOutputFramework/testFrameworkBundleId/$target/Foo.framework" - def bundleIdPattern = ~"CFBundleIdentifier\n\\s*Foo" - def bundleShortVersionStringPattern = ~"CFBundleShortVersionString\n\\s*FooBundleShortVersionString" - def bundleVersionPattern = ~"CFBundleVersion\n\\s*FooBundleVersion" - def plistContent = file("$frameworkPath/Resources/Info.plist").text - if (!bundleIdPattern.matcher(plistContent).find()) { - throw new Error("Unexpected CFBundleIdentifier in Info.plist:\n$plistContent") - } - if (!bundleShortVersionStringPattern.matcher(plistContent).find()) { - throw new Error("Unexpected CFBundleShortVersionString in Info.plist:\n$plistContent") - } - if (!bundleVersionPattern.matcher(plistContent).find()) { - throw new Error("Unexpected CFBundleVersion in Info.plist:\n$plistContent") - } - } - } - - frameworkTest("testForwardDeclarationsFramework") { - framework('ForwardDeclarations') { - sources = ['framework/forwardDeclarations'] - libraries = ['frameworkForwardDeclarations'] - } - swiftSources = ['framework/forwardDeclarations/'] - } - - frameworkTest("testFrameworkUsesFoundationModule") { - framework("Bar") { - sources = ["framework/use_foundation_module/framework.kt"] - } - swiftSources = [] - doLast { - def frameworkPath = "$testOutputFramework/testFrameworkUsesFoundationModule/$target/Bar.framework" - def moduleMapContent = file("$frameworkPath/Modules/module.modulemap").text - def useFoundationPattern = ~"use Foundation" - if (!useFoundationPattern.matcher(moduleMapContent).find()) { - throw new Error("Expected use of Foundation module:\n$moduleMapContent") - } - } - } - - frameworkTest("testKt56233Framework") { - framework("Kt56233") { - sources = ['framework/kt56233'] - } - swiftSources = ['framework/kt56233'] - if (isAggressiveGC) { - swiftExtraOpts += ["-D", "AGGRESSIVE_GC"] - } - } - - frameworkTest("testKt57791Framework") { - framework("Kt57791") { - sources = ['framework/kt57791'] - } - swiftSources = ['framework/kt57791'] - } - - frameworkTest("testPermanentObjectsFramework") { - enabled = !isNoopGC // Requires gc to actually happen. - framework("PermanentObjects") { - sources = ['framework/permanentObjects'] - opts = ['-opt-in=kotlin.native.internal.InternalForKotlinNative'] - } - swiftSources = ['framework/permanentObjects'] - } -} - tasks.register("override_konan_properties0", KonanDriverTest) { disabled = isAggressiveGC // No need to test with different GC schedulers def overrides = PlatformInfo.isWindows() diff --git a/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcodeSimulatorExecutor.kt b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcodeSimulatorExecutor.kt index 7d25c6c5eed..55bd1514d88 100644 --- a/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcodeSimulatorExecutor.kt +++ b/native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcodeSimulatorExecutor.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.* import java.io.ByteArrayOutputStream import java.io.File import java.util.logging.Logger +import kotlin.time.Duration private fun defaultDeviceId(target: KonanTarget) = when (target.family) { Family.TVOS -> "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K" @@ -162,4 +163,4 @@ class XcodeSimulatorExecutor( this.environment.putAll(env) }) } -} \ No newline at end of file +} diff --git a/kotlin-native/backend.native/tests/framework/abstractInstantiation/abstractInstantiation.kt b/native/native.tests/testData/framework/abstractInstantiation/abstractInstantiation.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/abstractInstantiation/abstractInstantiation.kt rename to native/native.tests/testData/framework/abstractInstantiation/abstractInstantiation.kt diff --git a/kotlin-native/backend.native/tests/framework/abstractInstantiation/abstractInstantiation.swift b/native/native.tests/testData/framework/abstractInstantiation/abstractInstantiation.swift similarity index 100% rename from kotlin-native/backend.native/tests/framework/abstractInstantiation/abstractInstantiation.swift rename to native/native.tests/testData/framework/abstractInstantiation/abstractInstantiation.swift diff --git a/kotlin-native/backend.native/tests/framework/bundle_id/lib.kt b/native/native.tests/testData/framework/bundle_id/lib.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/bundle_id/lib.kt rename to native/native.tests/testData/framework/bundle_id/lib.kt diff --git a/kotlin-native/backend.native/tests/framework/bundle_id/main.kt b/native/native.tests/testData/framework/bundle_id/main.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/bundle_id/main.kt rename to native/native.tests/testData/framework/bundle_id/main.kt diff --git a/kotlin-native/backend.native/tests/framework/forwardDeclarations/clib.def b/native/native.tests/testData/framework/forwardDeclarations/forwardDeclarations.def similarity index 100% rename from kotlin-native/backend.native/tests/framework/forwardDeclarations/clib.def rename to native/native.tests/testData/framework/forwardDeclarations/forwardDeclarations.def diff --git a/kotlin-native/backend.native/tests/framework/forwardDeclarations/lib.kt b/native/native.tests/testData/framework/forwardDeclarations/forwardDeclarations.kt similarity index 85% rename from kotlin-native/backend.native/tests/framework/forwardDeclarations/lib.kt rename to native/native.tests/testData/framework/forwardDeclarations/forwardDeclarations.kt index 280403c5b4e..68cf311430e 100644 --- a/kotlin-native/backend.native/tests/framework/forwardDeclarations/lib.kt +++ b/native/native.tests/testData/framework/forwardDeclarations/forwardDeclarations.kt @@ -1,4 +1,5 @@ -import clib.* +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +import forwardDeclarations.* import cnames.structs.ForwardDeclaredStruct import objcnames.classes.ForwardDeclaredClass import objcnames.protocols.ForwardDeclaredProtocolProtocol diff --git a/kotlin-native/backend.native/tests/framework/forwardDeclarations/test.swift b/native/native.tests/testData/framework/forwardDeclarations/forwardDeclarations.swift similarity index 80% rename from kotlin-native/backend.native/tests/framework/forwardDeclarations/test.swift rename to native/native.tests/testData/framework/forwardDeclarations/forwardDeclarations.swift index 1f965feda57..2ef5ebcb0c2 100644 --- a/kotlin-native/backend.native/tests/framework/forwardDeclarations/test.swift +++ b/native/native.tests/testData/framework/forwardDeclarations/forwardDeclarations.swift @@ -2,7 +2,7 @@ import ForwardDeclarations private func test1() throws { let ptr = UnsafeMutableRawPointer(bitPattern: 0x1234) - try assertEquals(actual: LibKt.sameForwardDeclaredStruct(ptr: ptr), expected: ptr) + try assertEquals(actual: ForwardDeclarationsKt.sameForwardDeclaredStruct(ptr: ptr), expected: ptr) // We can't actually test this, because Swift can't import neither types nor functions due to // "interface/protocol '...' is incomplete": @@ -16,7 +16,7 @@ private func test1() throws { // -------- Execution of the test -------- -class TestTests : SimpleTestProvider { +class ForwardDeclarationsTests : SimpleTestProvider { override init() { super.init() diff --git a/kotlin-native/backend.native/tests/framework/gh3343/objclib.def b/native/native.tests/testData/framework/gh3343/gh3343.def similarity index 51% rename from kotlin-native/backend.native/tests/framework/gh3343/objclib.def rename to native/native.tests/testData/framework/gh3343/gh3343.def index 5372fd7a975..d017d44e8ee 100644 --- a/kotlin-native/backend.native/tests/framework/gh3343/objclib.def +++ b/native/native.tests/testData/framework/gh3343/gh3343.def @@ -1,3 +1,3 @@ language = Objective-C headers = Foundation/NSArray.h Foundation/NSValue.h Foundation/NSString.h -headerFilter = **/objclib.h Foundation/NSArray.h Foundation/NSValue.h Foundation/NSString.h +headerFilter = gh3343.h Foundation/NSArray.h Foundation/NSValue.h Foundation/NSString.h diff --git a/kotlin-native/backend.native/tests/framework/gh3343/objclib.h b/native/native.tests/testData/framework/gh3343/gh3343.h similarity index 100% rename from kotlin-native/backend.native/tests/framework/gh3343/objclib.h rename to native/native.tests/testData/framework/gh3343/gh3343.h diff --git a/kotlin-native/backend.native/tests/framework/gh3343/ktlib.kt b/native/native.tests/testData/framework/gh3343/gh3343.kt similarity index 79% rename from kotlin-native/backend.native/tests/framework/gh3343/ktlib.kt rename to native/native.tests/testData/framework/gh3343/gh3343.kt index b20316f4c4d..a4573db4a81 100644 --- a/kotlin-native/backend.native/tests/framework/gh3343/ktlib.kt +++ b/native/native.tests/testData/framework/gh3343/gh3343.kt @@ -1,5 +1,6 @@ +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) import kotlinx.cinterop.* -import objclib.* +import gh3343.* import kotlin.native.ref.* fun run(): List { diff --git a/kotlin-native/backend.native/tests/framework/gh3343/uselib.swift b/native/native.tests/testData/framework/gh3343/gh3343.swift similarity index 89% rename from kotlin-native/backend.native/tests/framework/gh3343/uselib.swift rename to native/native.tests/testData/framework/gh3343/gh3343.swift index fc22748eec1..4fbc4de6ab8 100644 --- a/kotlin-native/backend.native/tests/framework/gh3343/uselib.swift +++ b/native/native.tests/testData/framework/gh3343/gh3343.swift @@ -2,7 +2,7 @@ import Foundation import Gh3343 func testGh3343() throws { - let list = KtlibKt.run() + let list = Gh3343Kt.run() try assertEquals(actual: list[0] as? String, expected: "42") try assertEquals(actual: list[1] as? Int, expected: 2) try assertEquals(actual: list[2] as? Int, expected: 117) @@ -11,7 +11,7 @@ func testGh3343() throws { // -------- Execution of the test -------- -class UselibTests : TestProvider { +class Gh3343Tests : TestProvider { var tests: [TestCase] = [] init() { diff --git a/kotlin-native/backend.native/tests/framework/kt42397/knlibrary.kt b/native/native.tests/testData/framework/kt42397/kt42397.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/kt42397/knlibrary.kt rename to native/native.tests/testData/framework/kt42397/kt42397.kt diff --git a/kotlin-native/backend.native/tests/framework/kt42397/test.swift b/native/native.tests/testData/framework/kt42397/kt42397.swift similarity index 92% rename from kotlin-native/backend.native/tests/framework/kt42397/test.swift rename to native/native.tests/testData/framework/kt42397/kt42397.swift index f1456a18ebc..2b2eac80c38 100644 --- a/kotlin-native/backend.native/tests/framework/kt42397/test.swift +++ b/native/native.tests/testData/framework/kt42397/kt42397.swift @@ -7,7 +7,7 @@ class Results { func runTestKt42397(pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? { autoreleasepool { - KnlibraryKt.enableMemoryChecker() + Kt42397Kt.enableMemoryChecker() let results = pointer.bindMemory(to: Results.self, capacity: 1).pointee results.aFoo = A().foo() results.bFoo = B.Companion().foo() @@ -31,7 +31,7 @@ func testKt42397() throws { // -------- Execution of the test -------- -class TestTests : SimpleTestProvider { +class Kt42397Tests : SimpleTestProvider { override init() { super.init() diff --git a/kotlin-native/backend.native/tests/framework/kt43517/kt43517.def b/native/native.tests/testData/framework/kt43517/kt43517.def similarity index 100% rename from kotlin-native/backend.native/tests/framework/kt43517/kt43517.def rename to native/native.tests/testData/framework/kt43517/kt43517.def diff --git a/kotlin-native/backend.native/tests/framework/kt43517/kt43517.kt b/native/native.tests/testData/framework/kt43517/kt43517.kt similarity index 77% rename from kotlin-native/backend.native/tests/framework/kt43517/kt43517.kt rename to native/native.tests/testData/framework/kt43517/kt43517.kt index 716dcd7e87e..510d957b72b 100644 --- a/kotlin-native/backend.native/tests/framework/kt43517/kt43517.kt +++ b/native/native.tests/testData/framework/kt43517/kt43517.kt @@ -1,3 +1,4 @@ +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) import kt43517.* fun produceEnum(): E = diff --git a/kotlin-native/backend.native/tests/framework/kt43517/kt43517.swift b/native/native.tests/testData/framework/kt43517/kt43517.swift similarity index 100% rename from kotlin-native/backend.native/tests/framework/kt43517/kt43517.swift rename to native/native.tests/testData/framework/kt43517/kt43517.swift diff --git a/kotlin-native/backend.native/tests/framework/kt56233/knlibrary.kt b/native/native.tests/testData/framework/kt56233/Kt56233.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/kt56233/knlibrary.kt rename to native/native.tests/testData/framework/kt56233/Kt56233.kt diff --git a/kotlin-native/backend.native/tests/framework/kt56233/test.swift b/native/native.tests/testData/framework/kt56233/Kt56233.swift similarity index 96% rename from kotlin-native/backend.native/tests/framework/kt56233/test.swift rename to native/native.tests/testData/framework/kt56233/Kt56233.swift index 6bbf8e3d412..1de9939a1c1 100644 --- a/kotlin-native/backend.native/tests/framework/kt56233/test.swift +++ b/native/native.tests/testData/framework/kt56233/Kt56233.swift @@ -40,7 +40,7 @@ func kt56233() { // -------- Execution of the test -------- -class TestTests : SimpleTestProvider { +class Kt56233Tests : SimpleTestProvider { override init() { super.init() diff --git a/kotlin-native/backend.native/tests/framework/kt57791/knlibrary.kt b/native/native.tests/testData/framework/kt57791/kt57791.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/kt57791/knlibrary.kt rename to native/native.tests/testData/framework/kt57791/kt57791.kt diff --git a/kotlin-native/backend.native/tests/framework/kt57791/test.swift b/native/native.tests/testData/framework/kt57791/kt57791.swift similarity index 77% rename from kotlin-native/backend.native/tests/framework/kt57791/test.swift rename to native/native.tests/testData/framework/kt57791/kt57791.swift index 2effdd63ecd..f4d29d3db35 100644 --- a/kotlin-native/backend.native/tests/framework/kt57791/test.swift +++ b/native/native.tests/testData/framework/kt57791/kt57791.swift @@ -6,10 +6,10 @@ class FooImpl : Foo { } func testKt57791() throws { - try assertTrue(KnlibraryKt.foobar(foo: FooImpl())) + try assertTrue(Kt57791Kt.foobar(foo: FooImpl())) } -class TestTests : TestProvider { +class Kt57791Tests : TestProvider { var tests: [TestCase] = [] init() { diff --git a/kotlin-native/backend.native/tests/framework/main.swift b/native/native.tests/testData/framework/main.swift similarity index 100% rename from kotlin-native/backend.native/tests/framework/main.swift rename to native/native.tests/testData/framework/main.swift diff --git a/kotlin-native/backend.native/tests/framework/multiple/framework1/first.kt b/native/native.tests/testData/framework/multiple/framework1/first.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/multiple/framework1/first.kt rename to native/native.tests/testData/framework/multiple/framework1/first.kt diff --git a/kotlin-native/backend.native/tests/framework/multiple/framework1/test.kt b/native/native.tests/testData/framework/multiple/framework1/test.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/multiple/framework1/test.kt rename to native/native.tests/testData/framework/multiple/framework1/test.kt diff --git a/kotlin-native/backend.native/tests/framework/multiple/framework2/second.kt b/native/native.tests/testData/framework/multiple/framework2/second.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/multiple/framework2/second.kt rename to native/native.tests/testData/framework/multiple/framework2/second.kt diff --git a/kotlin-native/backend.native/tests/framework/multiple/framework2/test.kt b/native/native.tests/testData/framework/multiple/framework2/test.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/multiple/framework2/test.kt rename to native/native.tests/testData/framework/multiple/framework2/test.kt diff --git a/kotlin-native/backend.native/tests/framework/multiple/multiple.swift b/native/native.tests/testData/framework/multiple/multiple.swift similarity index 100% rename from kotlin-native/backend.native/tests/framework/multiple/multiple.swift rename to native/native.tests/testData/framework/multiple/multiple.swift diff --git a/kotlin-native/backend.native/tests/framework/multiple/shared/shared.kt b/native/native.tests/testData/framework/multiple/shared/shared.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/multiple/shared/shared.kt rename to native/native.tests/testData/framework/multiple/shared/shared.kt diff --git a/kotlin-native/backend.native/tests/objcexport/coroutines.kt b/native/native.tests/testData/framework/objcexport/coroutines.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/coroutines.kt rename to native/native.tests/testData/framework/objcexport/coroutines.kt diff --git a/kotlin-native/backend.native/tests/objcexport/coroutines.swift b/native/native.tests/testData/framework/objcexport/coroutines.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/coroutines.swift rename to native/native.tests/testData/framework/objcexport/coroutines.swift diff --git a/kotlin-native/backend.native/tests/objcexport/dataClassComponentMethods.kt b/native/native.tests/testData/framework/objcexport/dataClassComponentMethods.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/dataClassComponentMethods.kt rename to native/native.tests/testData/framework/objcexport/dataClassComponentMethods.kt diff --git a/kotlin-native/backend.native/tests/objcexport/dataClassComponentMethods.swift b/native/native.tests/testData/framework/objcexport/dataClassComponentMethods.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/dataClassComponentMethods.swift rename to native/native.tests/testData/framework/objcexport/dataClassComponentMethods.swift diff --git a/kotlin-native/backend.native/tests/objcexport/deallocRetain.kt b/native/native.tests/testData/framework/objcexport/deallocRetain.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/deallocRetain.kt rename to native/native.tests/testData/framework/objcexport/deallocRetain.kt diff --git a/kotlin-native/backend.native/tests/objcexport/deallocRetain.swift b/native/native.tests/testData/framework/objcexport/deallocRetain.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/deallocRetain.swift rename to native/native.tests/testData/framework/objcexport/deallocRetain.swift diff --git a/kotlin-native/backend.native/tests/objcexport/enumValues.kt b/native/native.tests/testData/framework/objcexport/enumValues.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/enumValues.kt rename to native/native.tests/testData/framework/objcexport/enumValues.kt diff --git a/kotlin-native/backend.native/tests/objcexport/enumValues.swift b/native/native.tests/testData/framework/objcexport/enumValues.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/enumValues.swift rename to native/native.tests/testData/framework/objcexport/enumValues.swift diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazy.h b/native/native.tests/testData/framework/objcexport/expectedLazy.h similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/expectedLazy.h rename to native/native.tests/testData/framework/objcexport/expectedLazy.h diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h b/native/native.tests/testData/framework/objcexport/expectedLazyLegacySuspendUnit.h similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h rename to native/native.tests/testData/framework/objcexport/expectedLazyLegacySuspendUnit.h diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h b/native/native.tests/testData/framework/objcexport/expectedLazyNoGenerics.h similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h rename to native/native.tests/testData/framework/objcexport/expectedLazyNoGenerics.h diff --git a/kotlin-native/backend.native/tests/objcexport/funInterfaces.kt b/native/native.tests/testData/framework/objcexport/funInterfaces.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/funInterfaces.kt rename to native/native.tests/testData/framework/objcexport/funInterfaces.kt diff --git a/kotlin-native/backend.native/tests/objcexport/funInterfaces.swift b/native/native.tests/testData/framework/objcexport/funInterfaces.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/funInterfaces.swift rename to native/native.tests/testData/framework/objcexport/funInterfaces.swift diff --git a/kotlin-native/backend.native/tests/objcexport/functionalTypes.kt b/native/native.tests/testData/framework/objcexport/functionalTypes.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/functionalTypes.kt rename to native/native.tests/testData/framework/objcexport/functionalTypes.kt diff --git a/kotlin-native/backend.native/tests/objcexport/functionalTypes.swift b/native/native.tests/testData/framework/objcexport/functionalTypes.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/functionalTypes.swift rename to native/native.tests/testData/framework/objcexport/functionalTypes.swift diff --git a/kotlin-native/backend.native/tests/objcexport/gh4002.kt b/native/native.tests/testData/framework/objcexport/gh4002.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/gh4002.kt rename to native/native.tests/testData/framework/objcexport/gh4002.kt diff --git a/kotlin-native/backend.native/tests/objcexport/gh4002.swift b/native/native.tests/testData/framework/objcexport/gh4002.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/gh4002.swift rename to native/native.tests/testData/framework/objcexport/gh4002.swift diff --git a/kotlin-native/backend.native/tests/objcexport/headerWarnings.kt b/native/native.tests/testData/framework/objcexport/headerWarnings.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/headerWarnings.kt rename to native/native.tests/testData/framework/objcexport/headerWarnings.kt diff --git a/kotlin-native/backend.native/tests/objcexport/headerWarnings.swift b/native/native.tests/testData/framework/objcexport/headerWarnings.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/headerWarnings.swift rename to native/native.tests/testData/framework/objcexport/headerWarnings.swift diff --git a/kotlin-native/backend.native/tests/objcexport/hiddenfromobjc.kt b/native/native.tests/testData/framework/objcexport/hiddenfromobjc.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/hiddenfromobjc.kt rename to native/native.tests/testData/framework/objcexport/hiddenfromobjc.kt diff --git a/kotlin-native/backend.native/tests/objcexport/hiddenfromobjc.swift b/native/native.tests/testData/framework/objcexport/hiddenfromobjc.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/hiddenfromobjc.swift rename to native/native.tests/testData/framework/objcexport/hiddenfromobjc.swift diff --git a/kotlin-native/backend.native/tests/objcexport/interfaceMethodNameMangling.kt b/native/native.tests/testData/framework/objcexport/interfaceMethodNameMangling.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/interfaceMethodNameMangling.kt rename to native/native.tests/testData/framework/objcexport/interfaceMethodNameMangling.kt diff --git a/kotlin-native/backend.native/tests/objcexport/interfaceMethodNameMangling.swift b/native/native.tests/testData/framework/objcexport/interfaceMethodNameMangling.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/interfaceMethodNameMangling.swift rename to native/native.tests/testData/framework/objcexport/interfaceMethodNameMangling.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kdocExport.kt b/native/native.tests/testData/framework/objcexport/kdocExport.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kdocExport.kt rename to native/native.tests/testData/framework/objcexport/kdocExport.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kotlinPrivateOverride.kt b/native/native.tests/testData/framework/objcexport/kotlinPrivateOverride.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kotlinPrivateOverride.kt rename to native/native.tests/testData/framework/objcexport/kotlinPrivateOverride.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kotlinPrivateOverride.swift b/native/native.tests/testData/framework/objcexport/kotlinPrivateOverride.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kotlinPrivateOverride.swift rename to native/native.tests/testData/framework/objcexport/kotlinPrivateOverride.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt35940.kt b/native/native.tests/testData/framework/objcexport/kt35940.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt35940.kt rename to native/native.tests/testData/framework/objcexport/kt35940.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt35940.swift b/native/native.tests/testData/framework/objcexport/kt35940.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt35940.swift rename to native/native.tests/testData/framework/objcexport/kt35940.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt38641.kt b/native/native.tests/testData/framework/objcexport/kt38641.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt38641.kt rename to native/native.tests/testData/framework/objcexport/kt38641.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt38641.swift b/native/native.tests/testData/framework/objcexport/kt38641.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt38641.swift rename to native/native.tests/testData/framework/objcexport/kt38641.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt39206.kt b/native/native.tests/testData/framework/objcexport/kt39206.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt39206.kt rename to native/native.tests/testData/framework/objcexport/kt39206.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt39206.swift b/native/native.tests/testData/framework/objcexport/kt39206.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt39206.swift rename to native/native.tests/testData/framework/objcexport/kt39206.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt41907.kt b/native/native.tests/testData/framework/objcexport/kt41907.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt41907.kt rename to native/native.tests/testData/framework/objcexport/kt41907.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt41907.swift b/native/native.tests/testData/framework/objcexport/kt41907.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt41907.swift rename to native/native.tests/testData/framework/objcexport/kt41907.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt43599.kt b/native/native.tests/testData/framework/objcexport/kt43599.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt43599.kt rename to native/native.tests/testData/framework/objcexport/kt43599.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt43599.swift b/native/native.tests/testData/framework/objcexport/kt43599.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt43599.swift rename to native/native.tests/testData/framework/objcexport/kt43599.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt43780.kt b/native/native.tests/testData/framework/objcexport/kt43780.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt43780.kt rename to native/native.tests/testData/framework/objcexport/kt43780.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt43780.swift b/native/native.tests/testData/framework/objcexport/kt43780.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt43780.swift rename to native/native.tests/testData/framework/objcexport/kt43780.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt46431.kt b/native/native.tests/testData/framework/objcexport/kt46431.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt46431.kt rename to native/native.tests/testData/framework/objcexport/kt46431.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt46431.swift b/native/native.tests/testData/framework/objcexport/kt46431.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt46431.swift rename to native/native.tests/testData/framework/objcexport/kt46431.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt49937.kt b/native/native.tests/testData/framework/objcexport/kt49937.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt49937.kt rename to native/native.tests/testData/framework/objcexport/kt49937.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt49937.swift b/native/native.tests/testData/framework/objcexport/kt49937.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt49937.swift rename to native/native.tests/testData/framework/objcexport/kt49937.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt51593.kt b/native/native.tests/testData/framework/objcexport/kt51593.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt51593.kt rename to native/native.tests/testData/framework/objcexport/kt51593.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt54119.kt b/native/native.tests/testData/framework/objcexport/kt54119.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt54119.kt rename to native/native.tests/testData/framework/objcexport/kt54119.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt54119.swift b/native/native.tests/testData/framework/objcexport/kt54119.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt54119.swift rename to native/native.tests/testData/framework/objcexport/kt54119.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt55736.kt b/native/native.tests/testData/framework/objcexport/kt55736.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt55736.kt rename to native/native.tests/testData/framework/objcexport/kt55736.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt55736.swift b/native/native.tests/testData/framework/objcexport/kt55736.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt55736.swift rename to native/native.tests/testData/framework/objcexport/kt55736.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt56521.kt b/native/native.tests/testData/framework/objcexport/kt56521.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt56521.kt rename to native/native.tests/testData/framework/objcexport/kt56521.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt56521.swift b/native/native.tests/testData/framework/objcexport/kt56521.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt56521.swift rename to native/native.tests/testData/framework/objcexport/kt56521.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt57373.kt b/native/native.tests/testData/framework/objcexport/kt57373.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt57373.kt rename to native/native.tests/testData/framework/objcexport/kt57373.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt57373.swift b/native/native.tests/testData/framework/objcexport/kt57373.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt57373.swift rename to native/native.tests/testData/framework/objcexport/kt57373.swift diff --git a/kotlin-native/backend.native/tests/objcexport/kt57791.kt b/native/native.tests/testData/framework/objcexport/kt57791.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt57791.kt rename to native/native.tests/testData/framework/objcexport/kt57791.kt diff --git a/kotlin-native/backend.native/tests/objcexport/kt57791.swift b/native/native.tests/testData/framework/objcexport/kt57791.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/kt57791.swift rename to native/native.tests/testData/framework/objcexport/kt57791.swift diff --git a/kotlin-native/backend.native/tests/objcexport/library.kt b/native/native.tests/testData/framework/objcexport/library.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/library.kt rename to native/native.tests/testData/framework/objcexport/library.kt diff --git a/kotlin-native/backend.native/tests/objcexport/library.swift b/native/native.tests/testData/framework/objcexport/library.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/library.swift rename to native/native.tests/testData/framework/objcexport/library.swift diff --git a/kotlin-native/backend.native/tests/objcexport/library/library.kt b/native/native.tests/testData/framework/objcexport/library/library.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/library/library.kt rename to native/native.tests/testData/framework/objcexport/library/library.kt diff --git a/kotlin-native/backend.native/tests/objcexport/localEA.kt b/native/native.tests/testData/framework/objcexport/localEA.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/localEA.kt rename to native/native.tests/testData/framework/objcexport/localEA.kt diff --git a/kotlin-native/backend.native/tests/objcexport/localEA.swift b/native/native.tests/testData/framework/objcexport/localEA.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/localEA.swift rename to native/native.tests/testData/framework/objcexport/localEA.swift diff --git a/kotlin-native/backend.native/tests/objcexport/noAutorelease.kt b/native/native.tests/testData/framework/objcexport/noAutorelease.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/noAutorelease.kt rename to native/native.tests/testData/framework/objcexport/noAutorelease.kt diff --git a/kotlin-native/backend.native/tests/objcexport/noAutorelease.swift b/native/native.tests/testData/framework/objcexport/noAutorelease.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/noAutorelease.swift rename to native/native.tests/testData/framework/objcexport/noAutorelease.swift diff --git a/kotlin-native/backend.native/tests/objcexport/noEnumEntries/testEnum.kt b/native/native.tests/testData/framework/objcexport/noEnumEntries/testEnum.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/noEnumEntries/testEnum.kt rename to native/native.tests/testData/framework/objcexport/noEnumEntries/testEnum.kt diff --git a/kotlin-native/backend.native/tests/objcexport/objCName.swift b/native/native.tests/testData/framework/objcexport/objCName.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/objCName.swift rename to native/native.tests/testData/framework/objcexport/objCName.swift diff --git a/kotlin-native/backend.native/tests/objcexport/objCNameA.kt b/native/native.tests/testData/framework/objcexport/objCNameA.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/objCNameA.kt rename to native/native.tests/testData/framework/objcexport/objCNameA.kt diff --git a/kotlin-native/backend.native/tests/objcexport/objCNameB.kt b/native/native.tests/testData/framework/objcexport/objCNameB.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/objCNameB.kt rename to native/native.tests/testData/framework/objcexport/objCNameB.kt diff --git a/kotlin-native/backend.native/tests/objcexport/overrideKotlinMethods.kt b/native/native.tests/testData/framework/objcexport/overrideKotlinMethods.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/overrideKotlinMethods.kt rename to native/native.tests/testData/framework/objcexport/overrideKotlinMethods.kt diff --git a/kotlin-native/backend.native/tests/objcexport/overrideKotlinMethods.swift b/native/native.tests/testData/framework/objcexport/overrideKotlinMethods.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/overrideKotlinMethods.swift rename to native/native.tests/testData/framework/objcexport/overrideKotlinMethods.swift diff --git a/kotlin-native/backend.native/tests/objcexport/overrideMethodsOfAny.kt b/native/native.tests/testData/framework/objcexport/overrideMethodsOfAny.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/overrideMethodsOfAny.kt rename to native/native.tests/testData/framework/objcexport/overrideMethodsOfAny.kt diff --git a/kotlin-native/backend.native/tests/objcexport/overrideMethodsOfAny.swift b/native/native.tests/testData/framework/objcexport/overrideMethodsOfAny.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/overrideMethodsOfAny.swift rename to native/native.tests/testData/framework/objcexport/overrideMethodsOfAny.swift diff --git a/kotlin-native/backend.native/tests/objcexport/recursiveGenericArguments.kt b/native/native.tests/testData/framework/objcexport/recursiveGenericArguments.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/recursiveGenericArguments.kt rename to native/native.tests/testData/framework/objcexport/recursiveGenericArguments.kt diff --git a/kotlin-native/backend.native/tests/objcexport/recursiveGenericArguments.swift b/native/native.tests/testData/framework/objcexport/recursiveGenericArguments.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/recursiveGenericArguments.swift rename to native/native.tests/testData/framework/objcexport/recursiveGenericArguments.swift diff --git a/kotlin-native/backend.native/tests/objcexport/refined.kt b/native/native.tests/testData/framework/objcexport/refined.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/refined.kt rename to native/native.tests/testData/framework/objcexport/refined.kt diff --git a/kotlin-native/backend.native/tests/objcexport/refined.swift b/native/native.tests/testData/framework/objcexport/refined.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/refined.swift rename to native/native.tests/testData/framework/objcexport/refined.swift diff --git a/kotlin-native/backend.native/tests/objcexport/sealedClass.kt b/native/native.tests/testData/framework/objcexport/sealedClass.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/sealedClass.kt rename to native/native.tests/testData/framework/objcexport/sealedClass.kt diff --git a/kotlin-native/backend.native/tests/objcexport/sealedClass.swift b/native/native.tests/testData/framework/objcexport/sealedClass.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/sealedClass.swift rename to native/native.tests/testData/framework/objcexport/sealedClass.swift diff --git a/kotlin-native/backend.native/tests/objcexport/simpleClass.kt b/native/native.tests/testData/framework/objcexport/simpleClass.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/simpleClass.kt rename to native/native.tests/testData/framework/objcexport/simpleClass.kt diff --git a/kotlin-native/backend.native/tests/objcexport/swiftNameMangling.kt b/native/native.tests/testData/framework/objcexport/swiftNameMangling.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/swiftNameMangling.kt rename to native/native.tests/testData/framework/objcexport/swiftNameMangling.kt diff --git a/kotlin-native/backend.native/tests/objcexport/swiftNameMangling.swift b/native/native.tests/testData/framework/objcexport/swiftNameMangling.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/swiftNameMangling.swift rename to native/native.tests/testData/framework/objcexport/swiftNameMangling.swift diff --git a/kotlin-native/backend.native/tests/objcexport/throwableAsError.kt b/native/native.tests/testData/framework/objcexport/throwableAsError.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/throwableAsError.kt rename to native/native.tests/testData/framework/objcexport/throwableAsError.kt diff --git a/kotlin-native/backend.native/tests/objcexport/throwableAsError.swift b/native/native.tests/testData/framework/objcexport/throwableAsError.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/throwableAsError.swift rename to native/native.tests/testData/framework/objcexport/throwableAsError.swift diff --git a/kotlin-native/backend.native/tests/objcexport/throwsEmpty.kt b/native/native.tests/testData/framework/objcexport/throwsEmpty.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/throwsEmpty.kt rename to native/native.tests/testData/framework/objcexport/throwsEmpty.kt diff --git a/kotlin-native/backend.native/tests/objcexport/topLevelMangling.swift b/native/native.tests/testData/framework/objcexport/topLevelMangling.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/topLevelMangling.swift rename to native/native.tests/testData/framework/objcexport/topLevelMangling.swift diff --git a/kotlin-native/backend.native/tests/objcexport/topLevelManglingA.kt b/native/native.tests/testData/framework/objcexport/topLevelManglingA.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/topLevelManglingA.kt rename to native/native.tests/testData/framework/objcexport/topLevelManglingA.kt diff --git a/kotlin-native/backend.native/tests/objcexport/topLevelManglingB.kt b/native/native.tests/testData/framework/objcexport/topLevelManglingB.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/topLevelManglingB.kt rename to native/native.tests/testData/framework/objcexport/topLevelManglingB.kt diff --git a/kotlin-native/backend.native/tests/objcexport/values.kt b/native/native.tests/testData/framework/objcexport/values.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/values.kt rename to native/native.tests/testData/framework/objcexport/values.kt diff --git a/kotlin-native/backend.native/tests/objcexport/values.swift b/native/native.tests/testData/framework/objcexport/values.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/values.swift rename to native/native.tests/testData/framework/objcexport/values.swift diff --git a/kotlin-native/backend.native/tests/objcexport/variance.kt b/native/native.tests/testData/framework/objcexport/variance.kt similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/variance.kt rename to native/native.tests/testData/framework/objcexport/variance.kt diff --git a/kotlin-native/backend.native/tests/objcexport/variance.swift b/native/native.tests/testData/framework/objcexport/variance.swift similarity index 100% rename from kotlin-native/backend.native/tests/objcexport/variance.swift rename to native/native.tests/testData/framework/objcexport/variance.swift diff --git a/kotlin-native/backend.native/tests/framework/permanentObjects/knlibrary.kt b/native/native.tests/testData/framework/permanentObjects/permanentObjects.kt similarity index 92% rename from kotlin-native/backend.native/tests/framework/permanentObjects/knlibrary.kt rename to native/native.tests/testData/framework/permanentObjects/permanentObjects.kt index e6d13726290..354b8d306f0 100644 --- a/kotlin-native/backend.native/tests/framework/permanentObjects/knlibrary.kt +++ b/native/native.tests/testData/framework/permanentObjects/permanentObjects.kt @@ -1,7 +1,6 @@ @file:OptIn(kotlin.ExperimentalStdlibApi::class) import kotlin.native.internal.GC -import kotlin.native.internal.gc.GCInfo import kotlin.native.internal.isPermanent import kotlin.test.* diff --git a/kotlin-native/backend.native/tests/framework/permanentObjects/test.swift b/native/native.tests/testData/framework/permanentObjects/permanentObjects.swift similarity index 64% rename from kotlin-native/backend.native/tests/framework/permanentObjects/test.swift rename to native/native.tests/testData/framework/permanentObjects/permanentObjects.swift index 5fa78623d93..805d6b0ac2b 100644 --- a/kotlin-native/backend.native/tests/framework/permanentObjects/test.swift +++ b/native/native.tests/testData/framework/permanentObjects/permanentObjects.swift @@ -1,21 +1,21 @@ import PermanentObjects func testPermanentObjects() throws { - PermanentObjects.KnlibraryKt.assertIsPermanent() - let stableRefsBefore = PermanentObjects.KnlibraryKt.stableRefsCount() + PermanentObjects.PermanentObjectsKt.assertIsPermanent() + let stableRefsBefore = PermanentObjects.PermanentObjectsKt.stableRefsCount() autoreleasepool { for i in 0..<1000 { PermanentObjects.Permanent().counter += 1 } } - let stableRefsAfter = PermanentObjects.KnlibraryKt.stableRefsCount() + let stableRefsAfter = PermanentObjects.PermanentObjectsKt.stableRefsCount() try assertEquals(actual: PermanentObjects.Permanent().counter, expected: 1000) try assertEquals(actual: stableRefsAfter, expected: stableRefsBefore) } // -------- Execution of the test -------- -class TestTests : SimpleTestProvider { +class PermanentObjectsTests : SimpleTestProvider { override init() { super.init() diff --git a/kotlin-native/backend.native/tests/framework/stacktrace/stacktrace.kt b/native/native.tests/testData/framework/stacktrace/stacktrace.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/stacktrace/stacktrace.kt rename to native/native.tests/testData/framework/stacktrace/stacktrace.kt diff --git a/kotlin-native/backend.native/tests/framework/stacktrace/stacktrace.swift b/native/native.tests/testData/framework/stacktrace/stacktrace.swift similarity index 100% rename from kotlin-native/backend.native/tests/framework/stacktrace/stacktrace.swift rename to native/native.tests/testData/framework/stacktrace/stacktrace.swift diff --git a/kotlin-native/backend.native/tests/framework/stacktraceBridges/stacktraceBridges.kt b/native/native.tests/testData/framework/stacktraceBridges/stacktraceBridges.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/stacktraceBridges/stacktraceBridges.kt rename to native/native.tests/testData/framework/stacktraceBridges/stacktraceBridges.kt diff --git a/kotlin-native/backend.native/tests/framework/stacktraceBridges/stacktraceBridges.swift b/native/native.tests/testData/framework/stacktraceBridges/stacktraceBridges.swift similarity index 100% rename from kotlin-native/backend.native/tests/framework/stacktraceBridges/stacktraceBridges.swift rename to native/native.tests/testData/framework/stacktraceBridges/stacktraceBridges.swift diff --git a/kotlin-native/backend.native/tests/framework/stacktraceByLibbacktrace/stacktraceByLibbacktrace.kt b/native/native.tests/testData/framework/stacktraceByLibbacktrace/stacktraceByLibbacktrace.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/stacktraceByLibbacktrace/stacktraceByLibbacktrace.kt rename to native/native.tests/testData/framework/stacktraceByLibbacktrace/stacktraceByLibbacktrace.kt diff --git a/kotlin-native/backend.native/tests/framework/stacktraceByLibbacktrace/stacktraceByLibbacktrace.swift b/native/native.tests/testData/framework/stacktraceByLibbacktrace/stacktraceByLibbacktrace.swift similarity index 100% rename from kotlin-native/backend.native/tests/framework/stacktraceByLibbacktrace/stacktraceByLibbacktrace.swift rename to native/native.tests/testData/framework/stacktraceByLibbacktrace/stacktraceByLibbacktrace.swift diff --git a/kotlin-native/backend.native/tests/framework/stdlib/stdlib.kt b/native/native.tests/testData/framework/stdlib/stdlib.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/stdlib/stdlib.kt rename to native/native.tests/testData/framework/stdlib/stdlib.kt diff --git a/kotlin-native/backend.native/tests/framework/stdlib/stdlib.swift b/native/native.tests/testData/framework/stdlib/stdlib.swift similarity index 100% rename from kotlin-native/backend.native/tests/framework/stdlib/stdlib.swift rename to native/native.tests/testData/framework/stdlib/stdlib.swift diff --git a/kotlin-native/backend.native/tests/framework/use_foundation_module/framework.kt b/native/native.tests/testData/framework/use_foundation_module/use_foundation_module.kt similarity index 100% rename from kotlin-native/backend.native/tests/framework/use_foundation_module/framework.kt rename to native/native.tests/testData/framework/use_foundation_module/use_foundation_module.kt diff --git a/kotlin-native/backend.native/tests/framework/values_generics/values_generics.kt b/native/native.tests/testData/framework/values_generics/values_generics.kt similarity index 97% rename from kotlin-native/backend.native/tests/framework/values_generics/values_generics.kt rename to native/native.tests/testData/framework/values_generics/values_generics.kt index 58c0f1be3a3..5498ab8d97a 100644 --- a/kotlin-native/backend.native/tests/framework/values_generics/values_generics.kt +++ b/native/native.tests/testData/framework/values_generics/values_generics.kt @@ -8,10 +8,6 @@ package conversions -import kotlin.native.concurrent.isFrozen -import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KProperty - // Generics abstract class BaseData{ abstract fun asString():String diff --git a/kotlin-native/backend.native/tests/framework/values_generics/values.swift b/native/native.tests/testData/framework/values_generics/values_generics.swift similarity index 99% rename from kotlin-native/backend.native/tests/framework/values_generics/values.swift rename to native/native.tests/testData/framework/values_generics/values_generics.swift index 40acf24f573..4a7ef498870 100644 --- a/kotlin-native/backend.native/tests/framework/values_generics/values.swift +++ b/native/native.tests/testData/framework/values_generics/values_generics.swift @@ -272,7 +272,7 @@ func testGenericExtensions() throws { // -------- Execution of the test -------- -class ValuesTests : TestProvider { +class Values_genericsTests : TestProvider { var tests: [TestCase] = [] init() { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativeObjCExportTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativeObjCExportTest.kt index 471ea07c62b..58e0bf29fa5 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativeObjCExportTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativeObjCExportTest.kt @@ -34,7 +34,13 @@ abstract class AbstractNativeObjCExportTest : AbstractNativeSimpleTest() { .map { testPathFull.resolve(it) } ktSources.forEach { muteTestIfNecessary(it) } - val testCase: TestCase = generateObjCFrameworkTestCase(testPathFull, ktSources) + val testCase: TestCase = generateObjCFrameworkTestCase( + TestKind.STANDALONE, + TestCase.WithTestRunnerExtras(TestRunnerType.DEFAULT), + testPathFull.name, + ktSources, + TestCompilerArgs(listOf("-Xexport-kdoc")) + ) val objCFramework: ObjCFramework = testCase.toObjCFramework().assertSuccess().resultingArtifact val mainHeaderContents = objCFramework.mainHeader.readText() @@ -58,22 +64,4 @@ abstract class AbstractNativeObjCExportTest : AbstractNativeSimpleTest() { private fun TestCase.toObjCFramework(): TestCompilationResult { return testCompilationFactory.testCaseToObjCFrameworkCompilation(this, testRunSettings).result } - - private fun generateObjCFrameworkTestCase(testPathFull: File, sources: List): TestCase { - val moduleName: String = testPathFull.name - val module = TestModule.Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet(), emptySet()) - sources.forEach { module.files += TestFile.createCommitted(it, module) } - - return TestCase( - id = TestCaseId.Named(moduleName), - kind = TestKind.STANDALONE, - modules = setOf(module), - freeCompilerArgs = TestCompilerArgs(listOf("-Xexport-kdoc")), - nominalPackageName = PackageName(moduleName), - checks = TestRunChecks.Default(testRunSettings.get().executionTimeout), - extras = TestCase.WithTestRunnerExtras(TestRunnerType.DEFAULT) - ).apply { - initialize(null, null) - } - } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/FrameworkTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/FrameworkTest.kt new file mode 100644 index 00000000000..f14cee0da31 --- /dev/null +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/FrameworkTest.kt @@ -0,0 +1,490 @@ +/* + * 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.konan.test.blackbox + +import com.intellij.testFramework.TestDataPath +import org.jetbrains.kotlin.konan.target.Family +import org.jetbrains.kotlin.konan.test.blackbox.support.* +import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.* +import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationResult.Companion.assertSuccess +import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline +import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable +import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck +import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunChecks +import org.jetbrains.kotlin.konan.test.blackbox.support.settings.* +import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue +import org.junit.jupiter.api.Assumptions +import org.junit.jupiter.api.Tag +import org.junit.jupiter.api.Test +import java.io.File +import java.io.FileWriter +import kotlin.test.assertTrue + +@TestDataPath("\$PROJECT_ROOT") +class ClassicFrameworkTest : FrameworkTestBase() + +@FirPipeline +@Tag("frontend-fir") +@TestDataPath("\$PROJECT_ROOT") +class FirFrameworkTest : FrameworkTestBase() + +abstract class FrameworkTestBase : AbstractNativeSimpleTest() { + private val testSuiteDir = File("native/native.tests/testData/framework") + private val extras = TestCase.NoTestRunnerExtras("There's no entrypoint in Swift program") + private val testCompilationFactory = TestCompilationFactory() + + @Test + fun testValuesGenerics() { + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + val testName = "values_generics" + + val testCase = generateObjCFrameworkTestCase( + TestKind.STANDALONE_NO_TR, extras, "ValuesGenerics", + listOf( + testSuiteDir.resolve(testName).resolve("$testName.kt"), + testSuiteDir.resolve("objcexport/values.kt"), + ), + freeCompilerArgs = TestCompilerArgs(listOf("-opt-in=kotlinx.cinterop.ExperimentalForeignApi")) + ) + testCompilationFactory.testCaseToObjCFrameworkCompilation(testCase, testRunSettings).result.assertSuccess() + + compileAndRunSwift(testName, testCase) + } + + @Test + fun testStdlib() { + val testName = "stdlib" + val testCase = generateObjCFramework(testName) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testMultipleFrameworks() { + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + val testName = "multiple" + + val testDir = testSuiteDir.resolve(testName) + val framework1Dir = testDir.resolve("framework1") + val sharedDir = testDir.resolve("shared") + val moduleName1st = "First" + val testCase1 = generateObjCFrameworkTestCase( + TestKind.STANDALONE_NO_TR, extras, moduleName1st, + listOf( + framework1Dir.resolve("first.kt"), + framework1Dir.resolve("test.kt"), + sharedDir.resolve("shared.kt"), + ), + TestCompilerArgs("-Xbinary=bundleId=$moduleName1st") + ) + testCompilationFactory.testCaseToObjCFrameworkCompilation(testCase1, testRunSettings).result.assertSuccess() + + val framework2Dir = testDir.resolve("framework2") + val moduleName2nd = "Second" + val testCase2 = generateObjCFrameworkTestCase( + TestKind.STANDALONE_NO_TR, extras, moduleName2nd, + listOf( + framework2Dir.resolve("second.kt"), + framework2Dir.resolve("test.kt"), + sharedDir.resolve("shared.kt"), + ), + TestCompilerArgs("-Xbinary=bundleId=$moduleName2nd") + ) + testCompilationFactory.testCaseToObjCFrameworkCompilation(testCase2, testRunSettings).result.assertSuccess() + + compileAndRunSwift(testName, testCase1) // testCase1 provides testRun parameters. testCase2 should have the same. + } + + @Test + fun testMultipleFrameworksStatic() { + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + val testName = "multiple" + + val testDir = testSuiteDir.resolve(testName) + val framework1Dir = testDir.resolve("framework1") + val sharedDir = testDir.resolve("shared") + val freeCompilerArgs = listOf("-Xstatic-framework", "-Xpre-link-caches=enable") + val moduleName1st = "First" + val defaultChecks = TestRunChecks.Default(testRunSettings.get().executionTimeout) + val checks = if (testRunSettings.get() != CacheMode.WithoutCache) { + // KT-34262, KT-65289: one assert in testIsolation4() fails with caches: + // try assertFalse(obj2 is First.KotlinBase) + defaultChecks.copy(exitCodeCheck = TestRunCheck.ExitCode.Expected(134)) + } else defaultChecks + val testCase1 = generateObjCFrameworkTestCase( + TestKind.STANDALONE_NO_TR, extras, moduleName1st, + listOf( + framework1Dir.resolve("first.kt"), + framework1Dir.resolve("test.kt"), + sharedDir.resolve("shared.kt"), + ), + freeCompilerArgs = TestCompilerArgs(freeCompilerArgs + "-Xbinary=bundleId=$moduleName1st"), + checks = checks, + ) + testCompilationFactory.testCaseToObjCFrameworkCompilation(testCase1, testRunSettings).result.assertSuccess() + + val framework2Dir = testDir.resolve("framework2") + val moduleName2nd = "Second" + val testCase2 = generateObjCFrameworkTestCase( + TestKind.STANDALONE_NO_TR, extras, moduleName2nd, + listOf( + framework2Dir.resolve("second.kt"), + framework2Dir.resolve("test.kt"), + sharedDir.resolve("shared.kt"), + ), freeCompilerArgs = TestCompilerArgs(freeCompilerArgs + "-Xbinary=bundleId=$moduleName2nd") + ) + testCompilationFactory.testCaseToObjCFrameworkCompilation(testCase2, testRunSettings).result.assertSuccess() + + compileAndRunSwift(testName, testCase1) + } + + @Test + fun testGH3343() { + val testName = "gh3343" + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + val freeCInteropArgs = TestCompilerArgs(emptyList(), cinteropArgs = listOf("-header", "$testName.h")) + val interopLibrary = compileCInterop(testName, freeCInteropArgs) + val testCase = generateObjCFramework(testName, emptyList(), setOf(TestModule.Given(interopLibrary.klibFile))) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testKT42397() { + val testName = "kt42397" + val testCase = generateObjCFramework(testName) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testKT43517() { + val testName = "kt43517" + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + val interopLibrary = compileCInterop(testName) + + val testCase = generateObjCFramework(testName, emptyList(), setOf(TestModule.Given(interopLibrary.klibFile))) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testStacktrace() { + val testName = "stacktrace" + Assumptions.assumeFalse(testRunSettings.get() == OptimizationMode.OPT) + + val testCase = generateObjCFramework(testName, listOf("-g")) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testStacktraceBridges() { + val testName = "stacktraceBridges" + Assumptions.assumeFalse(testRunSettings.get() == OptimizationMode.OPT) + + val testCase = generateObjCFramework(testName, listOf("-g")) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testStacktraceByLibbacktrace() { + Assumptions.assumeFalse(testRunSettings.get() == OptimizationMode.OPT) + val testName = "stacktraceByLibbacktrace" + val testCase = generateObjCFramework(testName, listOf("-g", "-Xbinary=sourceInfoType=libbacktrace")) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testAbstractInstantiation() { + val testName = "abstractInstantiation" + val checks = TestRunChecks.Default(testRunSettings.get().executionTimeout).copy( + exitCodeCheck = TestRunCheck.ExitCode.Expected(134) + ) + val testCase = generateObjCFramework(testName, checks = checks) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testFrameworkBundleId() { + Assumptions.assumeTrue(testRunSettings.get().testTarget.family == Family.OSX) + val testName = "bundle_id" + val testDir = testSuiteDir.resolve(testName) + val freeCompilerArgs = TestCompilerArgs( + listOf( + "-Xbinary=bundleId=$testName", + "-Xbinary=bundleVersion=FooBundleVersion", + "-Xbinary=bundleShortVersionString=FooBundleShortVersionString" + ) + ) + val testCase = generateObjCFrameworkTestCase( + TestKind.STANDALONE_NO_TR, extras, testName, + listOf( + testDir.resolve("main.kt"), + testDir.resolve("lib.kt"), + ), + freeCompilerArgs + ) + testCompilationFactory.testCaseToObjCFrameworkCompilation(testCase, testRunSettings).result.assertSuccess() + + val buildDir = testRunSettings.get().testBinariesDir + val infoPlist = buildDir.resolve("$testName.framework/Resources/Info.plist") + val infoPlistContents = infoPlist.readText() + listOf( + "CFBundleIdentifier\\s*$testName", + "CFBundleShortVersionString\\s*FooBundleShortVersionString", + "CFBundleVersion\\s*FooBundleVersion", + ).forEach { + assertTrue(infoPlistContents.contains(Regex(it))) { + "${infoPlist.absolutePath} does not contain pattern `$it`:\n$infoPlistContents" + } + } + } + + @Test + fun testForwardDeclarations() { + val testName = "forwardDeclarations" + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + val interopLibrary = compileCInterop(testName) + + val testCase = generateObjCFramework(testName, emptyList(), setOf(TestModule.Given(interopLibrary.klibFile))) + compileAndRunSwift(testName, testCase) + } + + private fun compileCInterop(testName: String, freeCInteropArgs: TestCompilerArgs = TestCompilerArgs.EMPTY) = + cinteropToLibrary( + targets = targets, + defFile = testSuiteDir.resolve(testName).resolve("$testName.def"), + outputDir = buildDir, + freeCompilerArgs = freeCInteropArgs + ).assertSuccess().resultingArtifact + + @Test + fun testUseFoundationModule() { + val testName = "use_foundation_module" + generateObjCFramework(testName) + val modulemap = buildDir.resolve("$testName.framework/Modules/module.modulemap") + val modulemapContents = modulemap.readText() + val expectedPattern = "use Foundation" + assertTrue(modulemapContents.contains(expectedPattern)) { + "${modulemap.absolutePath} must contain `$expectedPattern`:\n$modulemapContents" + } + } + + @Test + fun testKT56233() { + val testName = "kt56233" + // test must make huge amount of repetitions to make sure there's no race conditions, so bigger timeout is needed. Double is not enough + val checks = TestRunChecks.Default(testRunSettings.get().executionTimeout * 10) + val testCase = generateObjCFramework(testName, checks = checks) + val swiftExtraOpts = if (testRunSettings.get() != GCScheduler.AGGRESSIVE) listOf() else + listOf("-D", "AGGRESSIVE_GC") + compileAndRunSwift(testName, testCase, swiftExtraOpts) + } + + @Test + fun testKT57791() { + val testName = "kt57791" + val testCase = generateObjCFramework(testName) + compileAndRunSwift(testName, testCase) + } + + @Test + fun testPermanentObjects() { + val testName = "permanentObjects" + Assumptions.assumeFalse(testRunSettings.get() == GCType.NOOP) { "Test requires GC to actually happen" } + + val testCase = generateObjCFramework(testName, listOf("-opt-in=kotlin.native.internal.InternalForKotlinNative")) + compileAndRunSwift(testName, testCase) + } + + @Test + fun objCExportTest() { + objCExportTestImpl("", emptyList(), emptyList(), false) + } + + @Test + fun objCExportTestNoGenerics() { + objCExportTestImpl("NoGenerics", listOf("-Xno-objc-generics"), + listOf("-D", "NO_GENERICS"), false) + } + + @Test + fun objCExportTestLegacySuspendUnit() { + objCExportTestImpl("LegacySuspendUnit", listOf("-Xbinary=unitSuspendFunctionObjCExport=legacy"), + listOf("-D", "LEGACY_SUSPEND_UNIT_FUNCTION_EXPORT"), false) + } + + @Test + fun objCExportTestNoSwiftMemberNameMangling() { + objCExportTestImpl("NoSwiftMemberNameMangling", listOf("-Xbinary=objcExportDisableSwiftMemberNameMangling=true"), + listOf("-D", "DISABLE_MEMBER_NAME_MANGLING"), false) + } + + @Test + fun objCExportTestNoInterfaceMemberNameMangling() { + objCExportTestImpl("NoInterfaceMemberNameMangling", listOf("-Xbinary=objcExportIgnoreInterfaceMethodCollisions=true"), + listOf("-D", "DISABLE_INTERFACE_METHOD_NAME_MANGLING"), false) + } + + @Test + fun objCExportTestStatic() { + objCExportTestImpl("Static", listOf("-Xbinary=objcExportSuspendFunctionLaunchThreadRestriction=none"), + listOf("-D", "ALLOW_SUSPEND_ANY_THREAD"), true) + } + + private fun objCExportTestImpl( + suffix: String, + frameworkOpts: List, + swiftOpts: List, + isStaticFramework: Boolean, + ) { + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + // Compile a couple of KLIBs + val library = compileToLibrary( + testSuiteDir.resolve("objcexport/library"), + buildDir, + TestCompilerArgs("-Xshort-module-name=MyLibrary", "-module-name", "org.jetbrains.kotlin.native.test-library"), + emptyList(), + ) + val noEnumEntries = compileToLibrary( + testSuiteDir.resolve("objcexport/noEnumEntries"), + buildDir, + TestCompilerArgs( + "-Xshort-module-name=NoEnumEntriesLibrary", "-XXLanguage:-EnumEntries", + "-module-name", "org.jetbrains.kotlin.native.test-no-enum-entries-library", + ), + emptyList(), + ) + + // Convert KT sources into ObjC framework using two KLIbs + val objcExportTestSuiteDir = testSuiteDir.resolve("objcexport") + val ktFiles = objcExportTestSuiteDir.listFiles { file: File -> file.name.endsWith(".kt") } + assertTrue(ktFiles != null && ktFiles.isNotEmpty()) { + "Some .kt files must be in test folder $objcExportTestSuiteDir" + } + val frameworkName = "Kt" + val testCase = generateObjCFrameworkTestCase( + TestKind.STANDALONE_NO_TR, extras, "Kt", + ktFiles!!.toList(), + freeCompilerArgs = TestCompilerArgs( + frameworkOpts + listOfNotNull( + "-Xstatic-framework".takeIf { isStaticFramework }, + "-opt-in=kotlinx.cinterop.ExperimentalForeignApi", + "-Xexport-kdoc", + "-Xbinary=bundleId=foo.bar", + "-module-name", frameworkName, + ) + ), + givenDependencies = setOf(TestModule.Given(library.klibFile), TestModule.Given(noEnumEntries.klibFile)), + // test must make huge amount of repetitions to make sure there's no race conditions, so bigger timeout is needed. + checks = TestRunChecks.Default(testRunSettings.get().executionTimeout * 2), + ) + testCompilationFactory.testCaseToObjCFrameworkCompilation(testCase, testRunSettings, listOf(noEnumEntries)).result.assertSuccess() + + // compile Swift sources using generated ObjC framework + val swiftFiles = objcExportTestSuiteDir.listFiles { file: File -> file.name.endsWith(".swift") } + assertTrue(swiftFiles != null && swiftFiles.isNotEmpty()) { + "Some .swift files must be in test folder $objcExportTestSuiteDir" + } + val swiftExtraOpts = buildList { + addAll(swiftOpts) + if (testRunSettings.get() == GCScheduler.AGGRESSIVE) { + add("-D") + add("AGGRESSIVE_GC") + } + if (testRunSettings.get() == GCType.NOOP) { + add("-D") + add("NOOP_GC") + } + } + val successExecutable = compileSwift(swiftFiles!!.toList(), swiftExtraOpts) + val testExecutable = TestExecutable( + successExecutable.resultingArtifact, + successExecutable.loggedData, + listOf(TestName("objCExportTest$suffix")) + ) + runExecutableAndVerify(testCase, testExecutable) + + // check Info.plist for expected bundle identifier + val plistFName = if (targets.testTarget.family == Family.OSX) "Resources/Info.plist" else "Info.plist" + val infoPlist = buildDir.resolve("$frameworkName.framework/$plistFName") + val infoPlistContents = infoPlist.readText() + assertTrue(infoPlistContents.contains(Regex("CFBundleIdentifier\\s*foo.bar"))) { + "${infoPlist.absolutePath} does not contain expected pattern with `foo.bar`:\n$infoPlistContents" + } + } + + private fun generateObjCFramework( + name: String, + testCompilerArgs: List = emptyList(), + givenDependencies: Set = emptySet(), + checks: TestRunChecks = TestRunChecks.Default(testRunSettings.get().executionTimeout), + ): TestCase { + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + + val testCase = generateObjCFrameworkTestCase( + TestKind.STANDALONE_NO_TR, + extras, + name.replaceFirstChar { it.uppercase() }, + listOf(testSuiteDir.resolve(name).resolve("$name.kt")), + TestCompilerArgs(testCompilerArgs + listOf("-Xbinary=bundleId=$name")), + givenDependencies, + checks = checks, + ) + val objCFrameworkCompilation = testCompilationFactory.testCaseToObjCFrameworkCompilation(testCase, testRunSettings) + val success = objCFrameworkCompilation.result.assertSuccess() + codesign(success.resultingArtifact.frameworkDir.absolutePath) + + return testCase + } + + private fun compileAndRunSwift(testName: String, testCase: TestCase, swiftExtraOpts: List = emptyList()) { + val success = compileSwift(testName, swiftExtraOpts) + val testExecutable = TestExecutable( + success.resultingArtifact, + success.loggedData, + listOf(TestName(testName)) + ) + runExecutableAndVerify(testCase, testExecutable) + } + + private fun compileSwift( + name: String, + swiftExtraOpts: List, + ): TestCompilationResult.Success = + compileSwift(listOf(testSuiteDir.resolve(name).resolve("$name.swift")), swiftExtraOpts) + + private fun compileSwift( + testSources: List, + swiftExtraOpts: List, + ): TestCompilationResult.Success { + // create a test provider and get main entry point + val provider = buildDir.resolve("provider.swift") + FileWriter(provider).use { writer -> + val providers = testSources + .map { file -> + file.name.toString().removeSuffix(".swift").replaceFirstChar { it.uppercase() } + } + .map { "${it}Tests" } + + writer.write( + """ + |// THIS IS AUTOGENERATED FILE + |// This method is invoked by the main routine to get a list of tests + |func registerProviders() { + | ${providers.joinToString("\n ") { "$it()" }} + |} + """.trimMargin() + ) + } + + return SwiftCompilation( + testRunSettings, + testSources + listOf( + provider, + testSuiteDir.resolve("main.swift") + ), + TestCompilationArtifact.Executable(buildDir.resolve("swiftTestExecutable")), + swiftExtraOpts, + ).result.assertSuccess() + } +} diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt index eec5cc3bc1c..c876640eea7 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Binaries import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeTargets import org.jetbrains.kotlin.konan.test.blackbox.support.settings.PipelineType import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Timeouts +import org.jetbrains.kotlin.konan.test.blackbox.support.util.DEFAULT_MODULE_NAME import org.jetbrains.kotlin.konan.test.blackbox.support.util.LAUNCHER_MODULE_NAME import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.junit.jupiter.api.Assumptions @@ -270,6 +271,31 @@ internal fun AbstractNativeSimpleTest.generateCInteropTestCaseFromSingleDefFile( } } +internal fun AbstractNativeSimpleTest.generateObjCFrameworkTestCase( + kind: TestKind, + extras: TestCase.Extras, + moduleName: String, + sources: List, + freeCompilerArgs: TestCompilerArgs = TestCompilerArgs.EMPTY, + givenDependencies: Set? = null, + checks: TestRunChecks = TestRunChecks.Default(testRunSettings.get().executionTimeout), +): TestCase { + val module = TestModule.Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet(), emptySet()) + sources.forEach { module.files += TestFile.createCommitted(it, module) } + + return TestCase( + id = TestCaseId.Named(moduleName), + kind = kind, + modules = setOf(module), + freeCompilerArgs = freeCompilerArgs, + nominalPackageName = PackageName(moduleName), + checks = checks, + extras = extras, + ).apply { + initialize(givenDependencies, null) + } +} + private fun AbstractNativeSimpleTest.compileToLibrary( testCase: TestCase, outputDir: File, diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/LoggedData.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/LoggedData.kt index 177e0102b05..5b753b581c0 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/LoggedData.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/LoggedData.kt @@ -93,17 +93,28 @@ internal abstract class LoggedData { abstract class CompilerCall : LoggedData() class CInteropParameters( - private val extraArgs: Array, + private val args: List, private val defFile: File, private val environment: JVMEnvironment = JVMEnvironment() // Capture environment. ) : LoggedData() { override fun computeText() = buildString { - appendArguments("CINTEROP INVOCATION EXTRA ARGUMENTS:", extraArgs.toList()) + appendLine("TEST DEF FILE: ${defFile.canonicalPath}") + appendArguments("CINTEROP INVOCATION ARGUMENTS:", args) appendLine() appendLine(environment) + } + } + class SwiftCParameters( + private val args: List, + private val sources: List, + private val environment: JVMEnvironment = JVMEnvironment() // Capture environment. + ) : LoggedData() { + override fun computeText() = buildString { + appendList("TEST SWIFT SOURCES:", sources.map { it.absolutePath }) + appendArguments("SWIFTC INVOCATION ARGUMENTS:", args) appendLine() - appendLine("TEST DEF FILE: ${defFile.canonicalPath}") + appendLine(environment) } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/CompilationToolCall.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/CompilationToolCall.kt index c05730aa239..fe22626d65d 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/CompilationToolCall.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/CompilationToolCall.kt @@ -10,10 +10,17 @@ import org.jetbrains.kotlin.cli.common.messages.* import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl import org.jetbrains.kotlin.compilerRunner.processCompilerOutput import org.jetbrains.kotlin.config.Services +import org.jetbrains.kotlin.konan.target.AppleConfigurables +import org.jetbrains.kotlin.konan.target.HostManager import org.jetbrains.kotlin.konan.test.blackbox.support.NativeTestSupport import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeTargets import org.jetbrains.kotlin.native.executors.RunProcessException import org.jetbrains.kotlin.native.executors.runProcess +import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Settings +import org.jetbrains.kotlin.konan.test.blackbox.support.settings.configurables +import org.jetbrains.kotlin.native.executors.* +import org.jetbrains.kotlin.test.KtAssert.fail +import org.junit.jupiter.api.Assumptions import java.io.ByteArrayOutputStream import java.io.File import java.io.PrintStream @@ -119,12 +126,9 @@ internal fun callCompilerWithoutOutputInterceptor( @OptIn(ExperimentalTime::class) internal fun invokeCInterop( kotlinNativeClassLoader: ClassLoader, - targets: KotlinNativeTargets, - inputDef: File, outputLib: File, - extraArgs: Array + args: Array ): CompilationToolCallResult { - val args = arrayOf("-o", outputLib.canonicalPath, "-def", inputDef.canonicalPath, "-no-default-libs", "-target", targets.testTarget.name) val buildDir = KonanFile("${outputLib.canonicalPath}-build") val generatedDir = KonanFile(buildDir, "kotlin") val nativesDir = KonanFile(buildDir, "natives") @@ -138,7 +142,7 @@ internal fun invokeCInterop( entryPoint.invoke( interopClass.getDeclaredConstructor().newInstance(), "native", - args + extraArgs, + args, false, generatedDir.absolutePath, nativesDir.absolutePath, manifest.path, cstubsName // args for InternalInteropOptions() ) @@ -170,6 +174,36 @@ internal fun invokeCInterop( } } +internal fun invokeSwiftC( + settings: Settings, + args: List, +): CompilationToolCallResult { + val targets = settings.get() + Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily) + val configs = settings.configurables as AppleConfigurables + val swiftCompiler = configs.absoluteTargetToolchain + "/bin/swiftc" + val result = try { + runProcess(swiftCompiler, *args.toTypedArray()) { + timeout = Duration.parse("5m") + environment["DYLD_FALLBACK_FRAMEWORK_PATH"] = + File(configs.absoluteTargetToolchain).resolveSibling("ExtraFrameworks").absolutePath + } + } catch (rpe: RunProcessException) { + return CompilationToolCallResult( + exitCode = ExitCode.COMPILATION_ERROR, + toolOutput = "ARGS: $args\nSTDOUT: ${rpe.stdout}\nSTDERR: ${rpe.stderr}", + toolOutputHasErrors = true, + rpe.executionTime + ) + } + return CompilationToolCallResult( + exitCode = ExitCode.OK, + toolOutput = "ARGS: $args\nSTDOUT: ${result.stdout}\nSTDERR=${result.stderr}}", + toolOutputHasErrors = false, + result.executionTime + ) +} + internal fun codesign(path: String) { val executableAbsolutePath = "/usr/bin/codesign" val args = arrayOf("--verbose", "-s", "-", path) diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt index cccae13cb0c..f2965d52f05 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt @@ -7,6 +7,8 @@ package org.jetbrains.kotlin.konan.test.blackbox.support.compilation import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.konan.properties.resolvablePropertyList +import org.jetbrains.kotlin.konan.target.AppleConfigurables +import org.jetbrains.kotlin.konan.target.withOSVersion import org.jetbrains.kotlin.konan.test.blackbox.support.* import org.jetbrains.kotlin.konan.test.blackbox.support.TestCase.* import org.jetbrains.kotlin.konan.test.blackbox.support.TestModule.Companion.allDependsOn @@ -76,7 +78,16 @@ internal abstract class BasicCompilation( protected abstract fun applyDependencies(argsBuilder: ArgsBuilder) private fun ArgsBuilder.applyFreeArgs() { - add(freeCompilerArgs.compilerArgs) + when (this@BasicCompilation) { + is LibraryCompilation, is StaticCacheCompilation -> + // In TWO_STAGE_MULTI_MODULE mode, source->framework compilation is split to + // - `source -> klib` stage, + // - `klib -> static_cache stage(if caches enabled) and + // - klib+static_cache -> framework + // option `-Xstatic-framework` can be supplied only to `-p framework` stage, so must be filtered out for other stages + add(freeCompilerArgs.compilerArgs.filter { it != "-Xstatic-framework" }) + else -> add(freeCompilerArgs.compilerArgs) + } } private fun ArgsBuilder.applyCompilerPlugins() { @@ -159,6 +170,7 @@ internal abstract class SourceBasedCompilation( private val gcScheduler: GCScheduler, private val allocator: Allocator, private val pipelineType: PipelineType, + private val cacheMode: CacheMode, freeCompilerArgs: TestCompilerArgs, compilerPlugins: CompilerPlugins, override val sourceModules: Collection, @@ -190,6 +202,9 @@ internal abstract class SourceBasedCompilation( add("-friend-modules", friends.joinToString(File.pathSeparator) { friend -> friend.path }) } add(dependencies.includedLibraries) { include -> "-Xinclude=${include.path}" } + // static caches of distlibs should be used, like in old testinfra. Relates to KT-65289 for ObjC frameworks + cacheMode.staticCacheForDistributionLibrariesRootDir + ?.let { cacheRootDir -> add("-Xcache-directory=$cacheRootDir") } } private fun applyK2MPPArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { @@ -222,6 +237,7 @@ internal class LibraryCompilation( gcScheduler = settings.get(), allocator = settings.get(), pipelineType = settings.get(), + cacheMode = settings.get(), freeCompilerArgs = freeCompilerArgs, compilerPlugins = settings.get(), sourceModules = sourceModules, @@ -244,7 +260,8 @@ internal class ObjCFrameworkCompilation( freeCompilerArgs: TestCompilerArgs, sourceModules: Collection, dependencies: Iterable>, - expectedArtifact: ObjCFramework + expectedArtifact: ObjCFramework, + val exportedLibraries: Iterable = emptyList(), ) : SourceBasedCompilation( targets = settings.get(), home = settings.get(), @@ -257,6 +274,7 @@ internal class ObjCFrameworkCompilation( gcScheduler = settings.get(), allocator = settings.get(), pipelineType = settings.getStageDependentPipelineType(), + cacheMode = settings.get(), freeCompilerArgs = freeCompilerArgs, compilerPlugins = settings.get(), sourceModules = sourceModules, @@ -272,6 +290,14 @@ internal class ObjCFrameworkCompilation( ) super.applySpecificArgs(argsBuilder) } + + override fun applyDependencies(argsBuilder: ArgsBuilder) = with(argsBuilder) { + exportedLibraries.forEach { + assertTrue(it in dependencies.libraries) + add("-Xexport-library=${it.path}") + } + super.applyDependencies(argsBuilder) + } } internal class BinaryLibraryCompilation( @@ -292,6 +318,7 @@ internal class BinaryLibraryCompilation( gcScheduler = settings.get(), allocator = settings.get(), pipelineType = settings.getStageDependentPipelineType(), + cacheMode = settings.get(), freeCompilerArgs = freeCompilerArgs, compilerPlugins = settings.get(), sourceModules = sourceModules, @@ -328,7 +355,14 @@ internal class CInteropCompilation( ) : TestCompilation() { override val result: TestCompilationResult by lazy { - val extraArgsArray = buildList { + val args = buildList { + add("-def") + add(defFile.canonicalPath) + add("-target") + add(targets.testTarget.name) + add("-o") + add(expectedArtifact.klibFile.canonicalPath) + add("-no-default-libs") dependencies.forEach { add("-l") add(it.artifact.path) @@ -344,16 +378,14 @@ internal class CInteropCompilation( add("-DNS_FORMAT_ARGUMENT(A)=") add("-compiler-option") add("-I${defFile.parentFile}") - }.toTypedArray() + } - val loggedCInteropParameters = LoggedData.CInteropParameters(extraArgs = extraArgsArray, defFile = defFile) + val loggedCInteropParameters = LoggedData.CInteropParameters(args, defFile) val (loggedCall: LoggedData, immediateResult: TestCompilationResult.ImmediateResult) = try { val (exitCode, cinteropOutput, cinteropOutputHasErrors, duration) = invokeCInterop( classLoader.classLoader, - targets, - defFile, expectedArtifact.klibFile, - extraArgsArray + args.toTypedArray() ) val loggedInteropCall = LoggedData.CompilationToolCall( @@ -383,6 +415,56 @@ internal class CInteropCompilation( } } +internal class SwiftCompilation( + testRunSettings: Settings, + sources: List, + expectedArtifact: Executable, + swiftExtraOpts: List, +) : TestCompilation() { + override val result: TestCompilationResult by lazy { + val buildDir = testRunSettings.get().testBinariesDir + val configs = testRunSettings.configurables as AppleConfigurables + val swiftTarget = configs.targetTriple.withOSVersion(configs.osVersionMin).toString() + val args = swiftExtraOpts + sources.map { it.absolutePath } + listOf( + "-sdk", configs.absoluteTargetSysRoot, "-target", swiftTarget, + "-g", "-o", expectedArtifact.executableFile.absolutePath, + "-Xlinker", "-rpath", "-Xlinker", "@executable_path/Frameworks", + "-Xlinker", "-rpath", "-Xlinker", buildDir.absolutePath, + "-F", buildDir.absolutePath, + "-Xcc", "-Werror", // To fail compilation on warnings in framework header. + ) + + val loggedSwiftCParameters = LoggedData.SwiftCParameters(args, sources) + val (loggedCall: LoggedData, immediateResult: TestCompilationResult.ImmediateResult) = try { + val (exitCode, swiftcOutput, swiftcOutputHasErrors, duration) = + invokeSwiftC(testRunSettings, args) + + val loggedSwiftCCall = LoggedData.CompilationToolCall( + toolName = "SWIFTC", + input = null, + parameters = loggedSwiftCParameters, + exitCode = exitCode, + toolOutput = swiftcOutput, + toolOutputHasErrors = swiftcOutputHasErrors, + duration = duration + ) + val res = if (exitCode != ExitCode.OK || swiftcOutputHasErrors) + TestCompilationResult.CompilationToolFailure(loggedSwiftCCall) + else + TestCompilationResult.Success(expectedArtifact, loggedSwiftCCall) + + loggedSwiftCCall to res + } catch (unexpectedThrowable: Throwable) { + val loggedFailure = LoggedData.CompilationToolCallUnexpectedFailure(loggedSwiftCParameters, unexpectedThrowable) + val res = TestCompilationResult.UnexpectedFailure(loggedFailure) + + loggedFailure to res + } + expectedArtifact.logFile.writeText(loggedCall.toString()) + immediateResult + } +} + internal class ExecutableCompilation( settings: Settings, freeCompilerArgs: TestCompilerArgs, @@ -403,6 +485,7 @@ internal class ExecutableCompilation( gcScheduler = settings.get(), allocator = settings.get(), pipelineType = settings.getStageDependentPipelineType(), + cacheMode = settings.get(), freeCompilerArgs = freeCompilerArgs, compilerPlugins = settings.get(), sourceModules = sourceModules, diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt index 4344145933f..a5e8ab3dfa7 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt @@ -109,7 +109,11 @@ internal class TestCompilationFactory { } } - fun testCaseToObjCFrameworkCompilation(testCase: TestCase, settings: Settings): ObjCFrameworkCompilation { + fun testCaseToObjCFrameworkCompilation( + testCase: TestCase, + settings: Settings, + exportedLibraries: Iterable = emptyList(), + ): ObjCFrameworkCompilation { val cacheKey = ObjCFrameworkCacheKey(testCase.rootModules) cachedObjCFrameworkCompilations[cacheKey]?.let { return it } @@ -126,8 +130,9 @@ internal class TestCompilationFactory { freeCompilerArgs = testCase.freeCompilerArgs, sourceModules = sourceModules, dependencies = dependencies, + exportedLibraries = exportedLibraries, expectedArtifact = ObjCFramework( - settings.artifactDirForPackageName(testCase.nominalPackageName), + settings.get().testBinariesDir, testCase.nominalPackageName.compressedPackageName ) ) @@ -184,7 +189,8 @@ internal class TestCompilationFactory { } TestMode.TWO_STAGE_MULTI_MODULE -> { // Compile root modules to KLIB. Pass this KLIB as included dependency to executable compilation. - val klibCompilations = modulesToKlib(rootModules, freeCompilerArgs, produceStaticCache(), settings) + val klibCompilations = + modulesToKlib(rootModules, freeCompilerArgs, produceStaticCache(), settings) Pair( // Include just compiled KLIB as -Xinclude dependency.