[K/N] Make a reproducer test for KT-55938

^KT-55938
This commit is contained in:
Pavel Kunyavskiy
2023-01-16 16:58:57 +01:00
committed by Pavel Kunyavskiy
parent e5417e8381
commit fbc39fcab1
7 changed files with 73 additions and 0 deletions
@@ -4443,6 +4443,10 @@ if (PlatformInfo.isAppleTarget(project)) {
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"
}
createInterop("kt49034_struct") {
it.defFile 'interop/objc/kt49034/struct/kt49034.def'
@@ -5166,6 +5170,7 @@ if (PlatformInfo.isAppleTarget(project)) {
UtilsKt.codesign(project, "$buildDir/libobjc_kt42172.dylib")
}
}
}
interopTest("interop_objc_kt48816_without_lazy_ir_for_caches") {
@@ -5197,6 +5202,34 @@ if (PlatformInfo.isAppleTarget(project)) {
interop = "objc_kt53151"
}
interopTest("interop_objc_kt55938") {
source = "interop/objc/kt55938/main.kt"
lib = "interop/objc/kt55938/lib.kt"
interop = "objc_kt55938"
useGoldenData = true
enabled = cacheTesting != null
flags = [
"-Xauto-cache-from=$testOutputRoot/local/objc_kt55938",
"-Xauto-cache-from=$testOutputRoot/local/interop_objc_kt55938",
"-Xauto-cache-dir=$testOutputRoot/local/interop_objc_kt55938/cache",
"-Werror" // to forbid retry with auto-cache disabled
]
doBeforeBuild {
mkdir(buildDir)
def cacheDir = new File("-Xauto-cache-dir=$testOutputRoot/local/interop_objc_kt55938/cache")
cacheDir.deleteDir()
project.extensions.execClang.execClangForCompilerTests(project.target) {
args "$projectDir/interop/objc/kt55938/objclib.m"
args "-lobjc", '-fobjc-arc'
args '-fPIC', '-shared', '-o', "$buildDir/libobjc_kt55938.dylib"
}
if (UtilsKt.isSimulatorTarget(project, project.target)) {
UtilsKt.codesign(project, "$buildDir/libobjc_kt55938.dylib")
}
}
}
standaloneTest("objc_arc_contract") {
doBeforeBuild {
mkdir(buildDir)
@@ -0,0 +1,10 @@
/*
* 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 kt55938lib
import objclib.*
inline fun foo() = ObjCClass.foo()
@@ -0,0 +1,10 @@
/*
* 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.
*/
import kt55938lib.*
fun main() {
print("foo() call result is ${foo()}")
}
@@ -0,0 +1 @@
foo() call result is 42
@@ -0,0 +1,3 @@
language = Objective-C
headerFilter = **/objclib.h
linkerOpts = -lobjc_kt55938
@@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface ObjCClass : NSObject
+ (int)foo;
@end
@@ -0,0 +1,11 @@
#include "objclib.h"
@implementation ObjCClass {
}
+ (int)foo {
return 42;
}
@end