[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/NSString.h"
|
||||||
#import "Foundation/NSObject.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() {
|
fun main() {
|
||||||
assertEquals("42", Impl.stringProperty())
|
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)
|
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.
|
// ObjCExport tests.
|
||||||
|
|||||||
+19
-25
@@ -5,54 +5,48 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.konan.test.blackbox
|
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.ClassLevelProperty
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty
|
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.TestCase
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCompilerArgs
|
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.TestKind
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationResult.Companion.assertSuccess
|
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.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
|
import java.io.File
|
||||||
|
|
||||||
@TestDataPath("\$PROJECT_ROOT")
|
|
||||||
@EnforcedProperty(ClassLevelProperty.COMPILER_OUTPUT_INTERCEPTOR, "NONE")
|
@EnforcedProperty(ClassLevelProperty.COMPILER_OUTPUT_INTERCEPTOR, "NONE")
|
||||||
abstract class BaseCInteropCheckersTest : AbstractNativeSimpleTest() {
|
abstract class AbstractNativeCInteropExecutableTest : AbstractNativeSimpleTest() {
|
||||||
@Test
|
|
||||||
@TestMetadata(TEST_DATA_DIR)
|
protected fun runTest(@TestDataFile testDataDir: String) {
|
||||||
fun testBuilding() {
|
val defFile = File(testDataDir, "library.def")
|
||||||
val defFile = File(TEST_DATA_DIR, DEF_FILE)
|
|
||||||
muteCInteropTestIfNecessary(defFile, targets.testTarget)
|
muteCInteropTestIfNecessary(defFile, targets.testTarget)
|
||||||
|
|
||||||
|
val mFile = File(testDataDir, "library.m")
|
||||||
|
val ktFile = File(testDataDir, "usage.kt")
|
||||||
|
|
||||||
val library = cinteropToLibrary(
|
val library = cinteropToLibrary(
|
||||||
targets = targets,
|
targets = targets,
|
||||||
defFile = defFile,
|
defFile = defFile,
|
||||||
outputDir = buildDir,
|
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
|
).assertSuccess().resultingArtifact
|
||||||
|
|
||||||
val testCase = generateTestCaseWithSingleFile(
|
val testCase = generateTestCaseWithSingleFile(
|
||||||
sourceFile = File(TEST_DATA_DIR, KT_FILE),
|
sourceFile = ktFile,
|
||||||
freeCompilerArgs = TestCompilerArgs(testRunSettings.get<PipelineType>().compilerFlags),
|
freeCompilerArgs = TestCompilerArgs(testRunSettings.get<PipelineType>().compilerFlags),
|
||||||
testKind = TestKind.STANDALONE_NO_TR,
|
testKind = TestKind.STANDALONE_NO_TR,
|
||||||
extras = TestCase.NoTestRunnerExtras("main")
|
extras = TestCase.NoTestRunnerExtras("main")
|
||||||
)
|
)
|
||||||
val compilationResult = compileToExecutable(testCase, library.asLibraryDependency()).assertSuccess()
|
val compilationResult = compileToExecutable(testCase, library.asLibraryDependency()).assertSuccess()
|
||||||
}
|
val testExecutable = TestExecutable.fromCompilationResult(testCase, compilationResult)
|
||||||
|
runExecutableAndVerify(testCase, testExecutable)
|
||||||
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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CInteropCheckersTest : BaseCInteropCheckersTest()
|
|
||||||
|
|
||||||
@FirPipeline
|
|
||||||
@Tag("frontend-fir")
|
|
||||||
class FirCInteropCheckersTest : BaseCInteropCheckersTest()
|
|
||||||
Reference in New Issue
Block a user