[K/N][Tests] Migrate tests kt49034*.kt
^KT-61259
This commit is contained in:
committed by
Space Team
parent
ae09c0fb60
commit
bd688b3ef7
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 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.
|
||||||
|
*/
|
||||||
|
// TARGET_BACKEND: NATIVE
|
||||||
|
// `import objcnames` somehow works only with NATIVE_STANDALONE test directive
|
||||||
|
// NATIVE_STANDALONE
|
||||||
|
// The test checks no collision between kt49034.__darwin_fp_control and platform.posix.__darwin_fp_control
|
||||||
|
// The test makes sense only on Apple x64 targets, where `class __darwin_fp_control` present in posix platform lib
|
||||||
|
// DISABLE_NATIVE: isAppleTarget=false
|
||||||
|
// DISABLE_NATIVE: targetArchitecture=ARM64
|
||||||
|
|
||||||
|
// MODULE: cinterop
|
||||||
|
// FILE: kt49034.def
|
||||||
|
headers = kt49034.h
|
||||||
|
language = Objective-C
|
||||||
|
|
||||||
|
// FILE: kt49034.h
|
||||||
|
@class __darwin_fp_control;
|
||||||
|
void foo(__darwin_fp_control*);
|
||||||
|
|
||||||
|
// MODULE: main(cinterop)
|
||||||
|
// FILE: main.kt
|
||||||
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
import objcnames.classes.__darwin_fp_control
|
||||||
|
|
||||||
|
open class C<T : kotlinx.cinterop.ObjCObject>
|
||||||
|
|
||||||
|
class D : C<__darwin_fp_control>()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
println(D())
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: checkPlatformDarwinFPControl.kt
|
||||||
|
import platform.posix.__darwin_fp_control
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 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.
|
||||||
|
*/
|
||||||
|
// TARGET_BACKEND: NATIVE
|
||||||
|
// The test depends on collision between kt49034.JSContext and platform.JavaScriptCore.JSContext
|
||||||
|
// DISABLE_NATIVE: isAppleTarget=false
|
||||||
|
// There is no JavaScriptCore on watchOS.
|
||||||
|
// DISABLE_NATIVE: targetFamily=WATCHOS
|
||||||
|
|
||||||
|
// MODULE: cinterop
|
||||||
|
// FILE: kt49034.def
|
||||||
|
headers = kt49034.h
|
||||||
|
|
||||||
|
// FILE: kt49034.h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct JSContext;
|
||||||
|
|
||||||
|
struct JSContext* bar();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// FILE: impl.c
|
||||||
|
#include "kt49034.h"
|
||||||
|
|
||||||
|
struct JSContext {
|
||||||
|
int field;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct JSContext global = { 15 };
|
||||||
|
|
||||||
|
extern "C" struct JSContext* bar() {
|
||||||
|
return &global;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: main(cinterop)
|
||||||
|
// FILE: main.kt
|
||||||
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
import kt49034.bar
|
||||||
|
import cnames.structs.JSContext
|
||||||
|
import kotlinx.cinterop.CPointer
|
||||||
|
|
||||||
|
fun baz(s: CPointer<JSContext>) {
|
||||||
|
println(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
baz(bar()!!)
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: checkPlatformJavaScriptCore.kt
|
||||||
|
import platform.JavaScriptCore.JSContext
|
||||||
@@ -1170,20 +1170,6 @@ if (PlatformInfo.isAppleTarget(project)) {
|
|||||||
it.headers "$projectDir/interop/objc/kt55938/objclib.h"
|
it.headers "$projectDir/interop/objc/kt55938/objclib.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("kt49034_struct") {
|
|
||||||
it.defFile 'interop/objc/kt49034/struct/kt49034.def'
|
|
||||||
it.headers "$projectDir/interop/objc/kt49034/struct/kt49034.h"
|
|
||||||
it.extraOpts "-Xcompile-source", "$projectDir/interop/objc/kt49034/struct/impl.c"
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("kt49034_objcclass") {
|
|
||||||
it.defFile 'interop/objc/kt49034/objcclass/kt49034.def'
|
|
||||||
it.headers "$projectDir/interop/objc/kt49034/objcclass/kt49034.h"
|
|
||||||
}
|
|
||||||
createInterop("kt49034_objcprotocol") {
|
|
||||||
it.defFile 'interop/objc/kt49034/objcprotocol/kt49034.def'
|
|
||||||
it.headers "$projectDir/interop/objc/kt49034/objcprotocol/kt49034.h"
|
|
||||||
}
|
|
||||||
createInterop("objc_include_categories") {
|
createInterop("objc_include_categories") {
|
||||||
it.defFile 'interop/objc/include_categories/objc_include_categories.def'
|
it.defFile 'interop/objc/include_categories/objc_include_categories.def'
|
||||||
it.headers "$projectDir/interop/objc/include_categories/objc_include_categories.h"
|
it.headers "$projectDir/interop/objc/include_categories/objc_include_categories.h"
|
||||||
@@ -1471,24 +1457,6 @@ if (PlatformInfo.isAppleTarget(project)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-49034 tests don't need whole compilation pipeline (only frontend) or platform libraries. Consider simplifying them when porting
|
|
||||||
// to the new test infra.
|
|
||||||
interopTest("interop_kt49034_struct") {
|
|
||||||
interop = 'kt49034_struct'
|
|
||||||
source = 'interop/objc/kt49034/struct/main.kt'
|
|
||||||
|
|
||||||
// The test depends on collision between kt49034.JSContext and platform.JavaScriptCore.JSContext
|
|
||||||
UtilsKt.dependsOnPlatformLibs(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_kt49034_objcclass") {
|
|
||||||
interop = 'kt49034_objcclass'
|
|
||||||
source = 'interop/objc/kt49034/objcclass/main.kt'
|
|
||||||
|
|
||||||
// The test depends on collision between kt49034.__darwin_fp_control and platform.darwin.__darwin_fp_control
|
|
||||||
UtilsKt.dependsOnPlatformLibs(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
standaloneTest("interop_objc_kt61441") {
|
standaloneTest("interop_objc_kt61441") {
|
||||||
source = "interop/objc/kt61441.kt"
|
source = "interop/objc/kt61441.kt"
|
||||||
UtilsKt.dependsOnPlatformLibs(it)
|
UtilsKt.dependsOnPlatformLibs(it)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
language = Objective-C
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
@class __darwin_fp_control;
|
|
||||||
void foo(__darwin_fp_control*);
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2022 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.
|
|
||||||
*/
|
|
||||||
import objcnames.classes.__darwin_fp_control
|
|
||||||
|
|
||||||
open class C<T : kotlinx.cinterop.ObjCObject>
|
|
||||||
|
|
||||||
class D : C<__darwin_fp_control>()
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
println(D())
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2022 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import kt49034.bar
|
|
||||||
import cnames.structs.JSContext
|
|
||||||
import kotlinx.cinterop.CPointer
|
|
||||||
|
|
||||||
fun baz(s: CPointer<JSContext>) {
|
|
||||||
println(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
baz(bar()!!)
|
|
||||||
}
|
|
||||||
+12
@@ -5092,6 +5092,18 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
|||||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt49034_objcclass.kt")
|
||||||
|
public void testKt49034_objcclass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt49034_objcclass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt49034_struct.kt")
|
||||||
|
public void testKt49034_struct() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt49034_struct.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt53151.kt")
|
@TestMetadata("kt53151.kt")
|
||||||
public void testKt53151() throws Exception {
|
public void testKt53151() throws Exception {
|
||||||
|
|||||||
+12
@@ -5208,6 +5208,18 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
|||||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt49034_objcclass.kt")
|
||||||
|
public void testKt49034_objcclass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt49034_objcclass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt49034_struct.kt")
|
||||||
|
public void testKt49034_struct() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt49034_struct.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt53151.kt")
|
@TestMetadata("kt53151.kt")
|
||||||
public void testKt53151() throws Exception {
|
public void testKt53151() throws Exception {
|
||||||
|
|||||||
+12
@@ -4976,6 +4976,18 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt49034_objcclass.kt")
|
||||||
|
public void testKt49034_objcclass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt49034_objcclass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt49034_struct.kt")
|
||||||
|
public void testKt49034_struct() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt49034_struct.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt53151.kt")
|
@TestMetadata("kt53151.kt")
|
||||||
public void testKt53151() throws Exception {
|
public void testKt53151() throws Exception {
|
||||||
|
|||||||
+12
@@ -5093,6 +5093,18 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
|||||||
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt48816_lazy_ir_enable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt49034_objcclass.kt")
|
||||||
|
public void testKt49034_objcclass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt49034_objcclass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt49034_struct.kt")
|
||||||
|
public void testKt49034_struct() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/cinterop/objc/kt49034_struct.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt53151.kt")
|
@TestMetadata("kt53151.kt")
|
||||||
public void testKt53151() throws Exception {
|
public void testKt53151() throws Exception {
|
||||||
|
|||||||
+4
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
|||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
|
import org.jetbrains.kotlin.konan.target.Architecture
|
||||||
import org.jetbrains.kotlin.konan.target.Family
|
import org.jetbrains.kotlin.konan.target.Family
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.*
|
import org.jetbrains.kotlin.konan.test.blackbox.support.*
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCase.WithTestRunnerExtras
|
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCase.WithTestRunnerExtras
|
||||||
@@ -933,12 +934,14 @@ private fun Settings.isIgnoredWithIGNORE_BACKEND(directives: Directives): Boolea
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val TARGET_FAMILY = "targetFamily"
|
private val TARGET_FAMILY = "targetFamily"
|
||||||
|
private val TARGET_ARCHITECTURE = "targetArchitecture"
|
||||||
private val IS_APPLE_TARGET = "isAppleTarget"
|
private val IS_APPLE_TARGET = "isAppleTarget"
|
||||||
private val CACHE_MODE_NAMES = CacheMode.Alias.entries.map { it.name }
|
private val CACHE_MODE_NAMES = CacheMode.Alias.entries.map { it.name }
|
||||||
private val TEST_MODE_NAMES = TestMode.entries.map { it.name }
|
private val TEST_MODE_NAMES = TestMode.entries.map { it.name }
|
||||||
private val OPTIMIZATION_MODE_NAMES = OptimizationMode.entries.map { it.name }
|
private val OPTIMIZATION_MODE_NAMES = OptimizationMode.entries.map { it.name }
|
||||||
private val GC_TYPE_NAMES = GCType.entries.map { it.name }
|
private val GC_TYPE_NAMES = GCType.entries.map { it.name }
|
||||||
private val FAMILY_NAMES = Family.entries.map { it.name }
|
private val FAMILY_NAMES = Family.entries.map { it.name }
|
||||||
|
private val ARCHITECTURE_NAMES = Architecture.entries.map { it.name }
|
||||||
private val BOOLEAN_NAMES = listOf(true.toString(), false.toString())
|
private val BOOLEAN_NAMES = listOf(true.toString(), false.toString())
|
||||||
|
|
||||||
private fun Settings.isDisabledNative(directives: Directives) =
|
private fun Settings.isDisabledNative(directives: Directives) =
|
||||||
@@ -965,6 +968,7 @@ private fun Settings.evaluate(directiveValues: List<String?>): Boolean {
|
|||||||
ClassLevelProperty.TEST_TARGET.shortName -> get<KotlinNativeTargets>().testTarget.name to null
|
ClassLevelProperty.TEST_TARGET.shortName -> get<KotlinNativeTargets>().testTarget.name to null
|
||||||
ClassLevelProperty.GC_TYPE.shortName -> get<GCType>().name to GC_TYPE_NAMES
|
ClassLevelProperty.GC_TYPE.shortName -> get<GCType>().name to GC_TYPE_NAMES
|
||||||
TARGET_FAMILY -> get<KotlinNativeTargets>().testTarget.family.name to FAMILY_NAMES
|
TARGET_FAMILY -> get<KotlinNativeTargets>().testTarget.family.name to FAMILY_NAMES
|
||||||
|
TARGET_ARCHITECTURE -> get<KotlinNativeTargets>().testTarget.architecture.name to ARCHITECTURE_NAMES
|
||||||
IS_APPLE_TARGET -> get<KotlinNativeTargets>().testTarget.family.isAppleFamily.toString() to BOOLEAN_NAMES
|
IS_APPLE_TARGET -> get<KotlinNativeTargets>().testTarget.family.isAppleFamily.toString() to BOOLEAN_NAMES
|
||||||
else -> throw AssertionError("ClassLevelProperty name: $propName is not yet supported in IGNORE_NATIVE* test directives.")
|
else -> throw AssertionError("ClassLevelProperty name: $propName is not yet supported in IGNORE_NATIVE* test directives.")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user