[KLIB] ABI reader: Tests for classes inherited from classes produced by Native interop tool
^KT-54402
This commit is contained in:
committed by
Space Team
parent
32e4b7a76f
commit
748eb2f9ee
+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.blackboxtest;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.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("compiler/util-klib-abi/testData/cinterop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@Tag("frontend-fir")
|
||||
@FirPipeline()
|
||||
public class FirNativeCInteropLibraryAbiReaderTest extends AbstractNativeCInteropLibraryAbiReaderTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInCinterop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/util-klib-abi/testData/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interop_class_inheritor.kt")
|
||||
public void testInterop_class_inheritor() throws Exception {
|
||||
runTest("compiler/util-klib-abi/testData/cinterop/interop_class_inheritor.kt");
|
||||
}
|
||||
}
|
||||
+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.blackboxtest;
|
||||
|
||||
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("compiler/util-klib-abi/testData/cinterop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class NativeCInteropLibraryAbiReaderTest extends AbstractNativeCInteropLibraryAbiReaderTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInCinterop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/util-klib-abi/testData/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interop_class_inheritor.kt")
|
||||
public void testInterop_class_inheritor() throws Exception {
|
||||
runTest("compiler/util-klib-abi/testData/cinterop/interop_class_inheritor.kt");
|
||||
}
|
||||
}
|
||||
+18
-1
@@ -275,7 +275,6 @@ fun main() {
|
||||
model("content", targetBackend = TargetBackend.NATIVE)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("native/native.tests/tests-gen", "compiler/util-klib-abi/testData") {
|
||||
testClass<AbstractNativeLibraryAbiReaderTest>(
|
||||
suiteTestClassName = "FirNativeLibraryAbiReaderTest",
|
||||
@@ -286,6 +285,24 @@ fun main() {
|
||||
model("content", targetBackend = TargetBackend.NATIVE)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("native/native.tests/tests-gen", "compiler/util-klib-abi/testData") {
|
||||
testClass<AbstractNativeCInteropLibraryAbiReaderTest>(
|
||||
suiteTestClassName = "NativeCInteropLibraryAbiReaderTest"
|
||||
) {
|
||||
model("cinterop")
|
||||
}
|
||||
}
|
||||
testGroup("native/native.tests/tests-gen", "compiler/util-klib-abi/testData") {
|
||||
testClass<AbstractNativeCInteropLibraryAbiReaderTest>(
|
||||
suiteTestClassName = "FirNativeCInteropLibraryAbiReaderTest",
|
||||
annotations = listOf(
|
||||
*frontendFir()
|
||||
)
|
||||
) {
|
||||
model("cinterop")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
-1
@@ -10,6 +10,10 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.TestCompilerArgs
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestDirectives
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestDirectives.MODULE
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.parseModule
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.ExistingDependency
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.util.getAbsoluteFile
|
||||
import org.jetbrains.kotlin.library.abi.*
|
||||
import org.jetbrains.kotlin.library.abi.directives.LibraryAbiDumpDirectives
|
||||
@@ -21,9 +25,11 @@ import org.jetbrains.kotlin.test.services.JUnit5Assertions
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEqualsToFile
|
||||
import org.jetbrains.kotlin.test.services.impl.RegisteredDirectivesParser
|
||||
import org.jetbrains.kotlin.test.services.impl.RegisteredDirectivesParser.ParsedDirective
|
||||
import org.jetbrains.kotlin.test.utils.withExtension
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
|
||||
import org.jetbrains.kotlin.utils.fileUtils.withReplacedExtensionOrNull
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Assumptions.assumeTrue
|
||||
import org.junit.jupiter.api.Tag
|
||||
import java.io.File
|
||||
|
||||
@@ -34,12 +40,16 @@ abstract class AbstractNativeLibraryAbiReaderTest : AbstractNativeSimpleTest() {
|
||||
val (sourceFile, dumpFiles) = computeTestFiles(localPath)
|
||||
val (moduleName, filters) = parseDirectives(sourceFile)
|
||||
|
||||
val customDependencies: List<ExistingDependency<TestCompilationArtifact.KLIB>> =
|
||||
produceCustomDependencies(sourceFile).map(TestCompilationArtifact.KLIB::asLibraryDependency)
|
||||
|
||||
val library = compileToLibrary(
|
||||
testCase = generateTestCaseWithSingleFile(
|
||||
sourceFile = sourceFile,
|
||||
moduleName = moduleName,
|
||||
freeCompilerArgs = TestCompilerArgs("-Xcontext-receivers")
|
||||
)
|
||||
),
|
||||
dependencies = customDependencies.toTypedArray()
|
||||
).resultingArtifact.klibFile
|
||||
|
||||
val libraryAbi = LibraryAbiReader.readAbiInfo(library, filters)
|
||||
@@ -54,6 +64,8 @@ abstract class AbstractNativeLibraryAbiReaderTest : AbstractNativeSimpleTest() {
|
||||
}
|
||||
}
|
||||
|
||||
internal open fun produceCustomDependencies(sourceFile: File): List<TestCompilationArtifact.KLIB> = emptyList()
|
||||
|
||||
companion object {
|
||||
private fun computeTestFiles(localPath: String): Pair<File, Map<AbiSignatureVersion, File>> {
|
||||
val sourceFile = getAbsoluteFile(localPath)
|
||||
@@ -98,3 +110,23 @@ abstract class AbstractNativeLibraryAbiReaderTest : AbstractNativeSimpleTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractNativeCInteropLibraryAbiReaderTest : AbstractNativeLibraryAbiReaderTest() {
|
||||
override fun produceCustomDependencies(sourceFile: File): List<TestCompilationArtifact.KLIB> {
|
||||
val targets: KotlinNativeTargets = testRunSettings.get()
|
||||
|
||||
assumeTrue(targets.hostTarget.family.isAppleFamily) // ObjC tests can run only on Apple targets.
|
||||
|
||||
val defFile = sourceFile.withExtension(".def")
|
||||
assertTrue(defFile.isFile) { "Def file does not exist: $defFile" }
|
||||
|
||||
return listOf(
|
||||
cinteropToLibrary(
|
||||
targets = targets,
|
||||
defFile = defFile,
|
||||
outputDir = buildDir,
|
||||
freeCompilerArgs = TestCompilerArgs.EMPTY
|
||||
).assertSuccess().resultingArtifact
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user