[K/N][Tests] Migrate first ObjC test with framework

^KT-61259
This commit is contained in:
Vladimir Sukharev
2024-01-17 11:49:34 +01:00
parent 6e2df0e086
commit 1b18f4ed1e
26 changed files with 263 additions and 35 deletions
@@ -6293,6 +6293,16 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -6293,6 +6293,16 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -6293,6 +6293,16 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
+39
View File
@@ -0,0 +1,39 @@
// TARGET_BACKEND: NATIVE
// DISABLE_NATIVE: isAppleTarget=false
// FREE_CINTEROP_ARGS: -compiler-option -F$generatedSourcesDir/cinterop
// MODULE: cinterop
// FILE: objclib.def
language = Objective-C
modules = Foo
---
static int getDefInt() {
return 2;
}
static int getFrameworkIntFromDef() {
return getFrameworkInt();
}
// FILE: Foo.framework/Headers/Foo.h
static int getFrameworkInt() {
return 1;
}
// FILE: Foo.framework/Modules/module.modulemap
framework module Foo {
umbrella header "Foo.h"
}
// MODULE: main(cinterop)
// FILE: main.kt
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
import kotlin.test.*
import objclib.*
fun box(): String {
assertEquals(1, getFrameworkInt())
assertEquals(2, getDefInt())
assertEquals(1, getFrameworkIntFromDef())
return "OK"
}
@@ -6293,6 +6293,16 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -6059,6 +6059,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -6293,6 +6293,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -6293,6 +6293,16 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -5510,6 +5510,19 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
}
}
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Objc extends AbstractLightAnalysisModeTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
}
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -4631,6 +4631,16 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -4631,6 +4631,16 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -4631,6 +4631,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -4631,6 +4631,16 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -1189,10 +1189,6 @@ if (PlatformInfo.isAppleTarget(project)) {
createInterop("objc_kt50648") {
it.defFile 'interop/objc/kt50648/objclib.def'
}
createInterop("objc_kt53151") {
it.defFile 'interop/objc/kt53151/objclib.def'
it.compilerOpts "-F$projectDir/interop/objc/kt53151/testFramework"
}
createInterop("objc_kt55938") {
it.defFile 'interop/objc/kt55938/objclib.def'
it.headers "$projectDir/interop/objc/kt55938/objclib.h"
@@ -1694,11 +1690,6 @@ if (PlatformInfo.isAppleTarget(project)) {
}
}
interopTest("interop_objc_kt53151") {
source = "interop/objc/kt53151/main.kt"
interop = "objc_kt53151"
}
interopTest("interop_objc_kt55938") {
source = "interop/objc/kt55938/main.kt"
lib = "interop/objc/kt55938/lib.kt"
@@ -1,8 +0,0 @@
import kotlin.test.*
import objclib.*
fun main() {
assertEquals(1, getFrameworkInt())
assertEquals(2, getDefInt())
assertEquals(1, getFrameworkIntFromDef())
}
@@ -1,10 +0,0 @@
language = Objective-C
modules = Foo
---
static int getDefInt() {
return 2;
}
static int getFrameworkIntFromDef() {
return getFrameworkInt();
}
@@ -1,3 +0,0 @@
static int getFrameworkInt() {
return 1;
}
@@ -1,3 +0,0 @@
framework module Foo {
umbrella header "Foo.h"
}
@@ -5056,6 +5056,25 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@FirPipeline()
@UseExtTestCaseGroupProvider()
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("kt53151.kt")
public void testKt53151() throws Exception {
runTest("compiler/testData/codegen/box/cinterop/objc/kt53151.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -5170,6 +5170,27 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@FirPipeline()
@UseExtTestCaseGroupProvider()
@UsePartialLinkage(mode = Mode.DISABLED)
@Tag("no-partial-linkage-may-be-skipped")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("kt53151.kt")
public void testKt53151() throws Exception {
runTest("compiler/testData/codegen/box/cinterop/objc/kt53151.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -4942,6 +4942,23 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
@UseExtTestCaseGroupProvider()
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("kt53151.kt")
public void testKt53151() throws Exception {
runTest("compiler/testData/codegen/box/cinterop/objc/kt53151.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -5057,6 +5057,25 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
@UseExtTestCaseGroupProvider()
@UsePartialLinkage(mode = Mode.DISABLED)
@Tag("no-partial-linkage-may-be-skipped")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("kt53151.kt")
public void testKt53151() throws Exception {
runTest("compiler/testData/codegen/box/cinterop/objc/kt53151.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -177,6 +177,7 @@ private class ExtTestDataFile(
args += "-opt-in=kotlin.native.internal.InternalForKotlinNativeTests" // for ReflectionPackageName
val freeCInteropArgs = structure.directives.listValues(FREE_CINTEROP_ARGS.name)
.orEmpty().flatMap { it.split(" ") }
.map { it.replace("\$generatedSourcesDir", testDataFileSettings.generatedSourcesDir.absolutePath) }
return TestCompilerArgs(args, freeCInteropArgs, testDataFileSettings.assertionsMode)
}
@@ -719,6 +720,7 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
source.files.forEach { extTestFile ->
val file = moduleDir.resolve(extTestFile.name)
file.parentFile.mkdirs()
file.writeText(extTestFile.text)
process(destination, TestFile.createCommitted(file, destination))
}
@@ -7,14 +7,15 @@ package org.jetbrains.kotlin.konan.test.blackbox.support.util
internal val Class<*>.sanitizedName: String get() = sanitize(name)
internal fun getSanitizedFileName(fileName: String): String = sanitize(fileName, allowDots = true)
internal fun getSanitizedFileName(fileName: String): String = sanitize(fileName, allowDots = true, allowSlashes = true)
private fun sanitize(s: String, allowDots: Boolean = false) = buildString {
private fun sanitize(s: String, allowDots: Boolean = false, allowSlashes: Boolean = false) = buildString {
s.forEach { ch ->
append(
when {
ch.isLetterOrDigit() || ch == '_' -> ch
allowDots && ch == '.' -> ch
allowSlashes && ch == '/' -> ch
else -> '_'
}
)
@@ -4613,6 +4613,16 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")
@@ -4613,6 +4613,16 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/objc")
@TestDataPath("$PROJECT_ROOT")
public class Objc {
@Test
public void testAllFilesPresentInObjc() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/cinterop/packages")
@TestDataPath("$PROJECT_ROOT")