[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
+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