[K/N] Create test model for building/executing C-Interop tests
^KT-63287 Fixed
This commit is contained in:
committed by
Space Team
parent
8d20d5b16c
commit
1b1df9f0db
@@ -0,0 +1,2 @@
|
||||
language = Objective-C
|
||||
headers = library.h
|
||||
-4
@@ -1,7 +1,3 @@
|
||||
depends = Foundation
|
||||
language = Objective-C
|
||||
|
||||
---
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSObject.h"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#import "library.h"
|
||||
|
||||
@implementation WithClassProperty : NSObject
|
||||
-(instancetype) init {}
|
||||
+ (NSString *) stringProperty { return @"153"; }
|
||||
@end
|
||||
+7
@@ -10,6 +10,13 @@ class Impl : WithClassProperty() {
|
||||
}
|
||||
}
|
||||
|
||||
@ObjCName("KotlinImplWithoutCompanionPropertyOverride")
|
||||
class ImplWithoutOverride : WithClassProperty() {
|
||||
companion object : WithClassPropertyMeta() {
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
assertEquals("42", Impl.stringProperty())
|
||||
assertEquals("153", ImplWithoutOverride.stringProperty())
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("native/native.tests/testData/CInterop/executable")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ClassicNativeCInteropExecutableTest extends AbstractNativeCInteropExecutableTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInExecutable() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CInterop/executable"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("KT-63048")
|
||||
public void testKT_63048() throws Exception {
|
||||
runTest("native/native.tests/testData/CInterop/executable/KT-63048/");
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.test.util.KtTestUtil;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("native/native.tests/testData/CInterop/executable")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@Tag("frontend-fir")
|
||||
@FirPipeline()
|
||||
public class FirNativeCInteropExecutableTest extends AbstractNativeCInteropExecutableTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInExecutable() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CInterop/executable"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("KT-63048")
|
||||
public void testKT_63048() throws Exception {
|
||||
runTest("native/native.tests/testData/CInterop/executable/KT-63048/");
|
||||
}
|
||||
}
|
||||
+14
@@ -183,6 +183,20 @@ fun main() {
|
||||
) {
|
||||
model("CInterop/experimental/cases", pattern = "^([^_](.+))$", recursive = false)
|
||||
}
|
||||
|
||||
testClass<AbstractNativeCInteropExecutableTest>(
|
||||
suiteTestClassName = "ClassicNativeCInteropExecutableTest",
|
||||
) {
|
||||
model("CInterop/executable", pattern = "^([^_](.+))$", recursive = false)
|
||||
}
|
||||
testClass<AbstractNativeCInteropExecutableTest>(
|
||||
suiteTestClassName = "FirNativeCInteropExecutableTest",
|
||||
annotations = listOf(
|
||||
*frontendFir()
|
||||
),
|
||||
) {
|
||||
model("CInterop/executable", pattern = "^([^_](.+))$", recursive = false)
|
||||
}
|
||||
}
|
||||
|
||||
// ObjCExport tests.
|
||||
|
||||
+19
-25
@@ -5,54 +5,48 @@
|
||||
|
||||
package org.jetbrains.kotlin.konan.test.blackbox
|
||||
|
||||
import com.intellij.testFramework.TestDataPath
|
||||
import com.intellij.testFramework.TestDataFile
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCase
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCompilerArgs
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestKind
|
||||
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.settings.PipelineType
|
||||
import org.jetbrains.kotlin.test.TestMetadata
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.io.File
|
||||
|
||||
@TestDataPath("\$PROJECT_ROOT")
|
||||
@EnforcedProperty(ClassLevelProperty.COMPILER_OUTPUT_INTERCEPTOR, "NONE")
|
||||
abstract class BaseCInteropCheckersTest : AbstractNativeSimpleTest() {
|
||||
@Test
|
||||
@TestMetadata(TEST_DATA_DIR)
|
||||
fun testBuilding() {
|
||||
val defFile = File(TEST_DATA_DIR, DEF_FILE)
|
||||
abstract class AbstractNativeCInteropExecutableTest : AbstractNativeSimpleTest() {
|
||||
|
||||
protected fun runTest(@TestDataFile testDataDir: String) {
|
||||
val defFile = File(testDataDir, "library.def")
|
||||
muteCInteropTestIfNecessary(defFile, targets.testTarget)
|
||||
|
||||
val mFile = File(testDataDir, "library.m")
|
||||
val ktFile = File(testDataDir, "usage.kt")
|
||||
|
||||
val library = cinteropToLibrary(
|
||||
targets = targets,
|
||||
defFile = defFile,
|
||||
outputDir = buildDir,
|
||||
freeCompilerArgs = TestCompilerArgs.EMPTY
|
||||
freeCompilerArgs = TestCompilerArgs(
|
||||
listOf(
|
||||
"-compiler-option", "-I$testDataDir",
|
||||
"-Xcompile-source", mFile.absolutePath,
|
||||
"-Xsource-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=",
|
||||
)
|
||||
)
|
||||
).assertSuccess().resultingArtifact
|
||||
|
||||
val testCase = generateTestCaseWithSingleFile(
|
||||
sourceFile = File(TEST_DATA_DIR, KT_FILE),
|
||||
sourceFile = ktFile,
|
||||
freeCompilerArgs = TestCompilerArgs(testRunSettings.get<PipelineType>().compilerFlags),
|
||||
testKind = TestKind.STANDALONE_NO_TR,
|
||||
extras = TestCase.NoTestRunnerExtras("main")
|
||||
)
|
||||
val compilationResult = compileToExecutable(testCase, library.asLibraryDependency()).assertSuccess()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TEST_DATA_DIR = "native/native.tests/testData/CInterop/KT-63048"
|
||||
const val DEF_FILE = "library.def"
|
||||
const val KT_FILE = "usage.kt"
|
||||
val testExecutable = TestExecutable.fromCompilationResult(testCase, compilationResult)
|
||||
runExecutableAndVerify(testCase, testExecutable)
|
||||
}
|
||||
}
|
||||
|
||||
class CInteropCheckersTest : BaseCInteropCheckersTest()
|
||||
|
||||
@FirPipeline
|
||||
@Tag("frontend-fir")
|
||||
class FirCInteropCheckersTest : BaseCInteropCheckersTest()
|
||||
Reference in New Issue
Block a user