[PL][tests] Rename KLIB ABI tests to Partial Linkage tests

This commit is contained in:
Dmitriy Dolovov
2023-03-28 14:20:11 +02:00
committed by Space Team
parent b677112992
commit 5f1c09cc24
11 changed files with 48 additions and 49 deletions
@@ -6,14 +6,14 @@
package org.jetbrains.kotlin.klib package org.jetbrains.kotlin.klib
import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.klib.KlibABITestUtils.ModuleBuildDirs.Companion.OUTPUT_DIR_NAME import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.ModuleBuildDirs.Companion.OUTPUT_DIR_NAME
import org.jetbrains.kotlin.klib.KlibABITestUtils.ModuleBuildDirs.Companion.SOURCE_DIR_NAME import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.ModuleBuildDirs.Companion.SOURCE_DIR_NAME
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.fail import org.junit.jupiter.api.fail
import java.io.File import java.io.File
object KlibABITestUtils { object PartialLinkageTestUtils {
interface TestConfiguration { interface TestConfiguration {
val testDir: File val testDir: File
val buildDir: File val buildDir: File
@@ -93,9 +93,9 @@ object KlibABITestUtils {
// Populate the source dir with *.kt files. // Populate the source dir with *.kt files.
copySources(from = moduleTestDir, to = moduleBuildDirs.sourceDir) copySources(from = moduleTestDir, to = moduleBuildDirs.sourceDir)
// Include ABI utils into the main module. // Include PL utils into the main module.
if (moduleName == MAIN_MODULE_NAME) { if (moduleName == MAIN_MODULE_NAME) {
val utilsDir = testDir.parentFile.resolve(ABI_UTILS_DIR) val utilsDir = testDir.parentFile.resolve(PL_UTILS_DIR)
KtUsefulTestCase.assertExists(utilsDir) KtUsefulTestCase.assertExists(utilsDir)
copySources(from = utilsDir, to = moduleBuildDirs.sourceDir) { contents -> copySources(from = utilsDir, to = moduleBuildDirs.sourceDir) { contents ->
@@ -208,6 +208,6 @@ object KlibABITestUtils {
) )
const val MAIN_MODULE_NAME = "main" const val MAIN_MODULE_NAME = "main"
private const val ABI_UTILS_DIR = "__utils__" private const val PL_UTILS_DIR = "__utils__"
private const val TEST_MODE_PLACEHOLDER = "TestMode.__UNKNOWN__" private const val TEST_MODE_PLACEHOLDER = "TestMode.__UNKNOWN__"
} }
@@ -38,12 +38,12 @@ fun main(args: Array<String>) {
} }
testGroup("js/js.tests/tests-gen", "compiler/testData") { testGroup("js/js.tests/tests-gen", "compiler/testData") {
testClass<AbstractJsKLibABIWithICTestCase> { testClass<AbstractJsPartialLinkageWithICTestCase> {
model("klibABI/", pattern = "^([^_](.+))$", targetBackend = TargetBackend.JS_IR, recursive = false, ) model("klibABI/", pattern = "^([^_](.+))$", targetBackend = TargetBackend.JS_IR, recursive = false, )
} }
} }
testGroup("js/js.tests/tests-gen", "compiler/testData") { testGroup("js/js.tests/tests-gen", "compiler/testData") {
testClass<AbstractJsKLibABINoICTestCase> { testClass<AbstractJsPartialLinkageNoICTestCase> {
model("klibABI/", pattern = "^([^_](.+))$", targetBackend = TargetBackend.JS_IR, recursive = false, ) model("klibABI/", pattern = "^([^_](.+))$", targetBackend = TargetBackend.JS_IR, recursive = false, )
} }
} }
@@ -30,8 +30,8 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImplForJsIC
import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.js.config.JSConfigurationKeys import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.js.testOld.V8IrJsTestChecker import org.jetbrains.kotlin.js.testOld.V8IrJsTestChecker
import org.jetbrains.kotlin.klib.KlibABITestUtils import org.jetbrains.kotlin.klib.PartialLinkageTestUtils
import org.jetbrains.kotlin.klib.KlibABITestUtils.MAIN_MODULE_NAME import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.MAIN_MODULE_NAME
import org.jetbrains.kotlin.konan.file.ZipFileSystemCacheableAccessor import org.jetbrains.kotlin.konan.file.ZipFileSystemCacheableAccessor
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
@@ -40,15 +40,15 @@ import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
import java.io.File import java.io.File
import kotlin.io.path.createTempDirectory import kotlin.io.path.createTempDirectory
abstract class AbstractJsKLibABIWithICTestCase : AbstractJsKLibABITestCase() { abstract class AbstractJsPartialLinkageWithICTestCase : AbstractJsPartialLinkageTestCase() {
override val useIncrementalCompiler get() = true override val useIncrementalCompiler get() = true
} }
abstract class AbstractJsKLibABINoICTestCase : AbstractJsKLibABITestCase() { abstract class AbstractJsPartialLinkageNoICTestCase : AbstractJsPartialLinkageTestCase() {
override val useIncrementalCompiler get() = false override val useIncrementalCompiler get() = false
} }
abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() { abstract class AbstractJsPartialLinkageTestCase : KtUsefulTestCase() {
abstract val useIncrementalCompiler: Boolean abstract val useIncrementalCompiler: Boolean
private lateinit var buildDir: File private lateinit var buildDir: File
@@ -86,17 +86,17 @@ abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() {
return config return config
} }
private inner class JsTestConfiguration(testPath: String) : KlibABITestUtils.TestConfiguration { private inner class JsTestConfiguration(testPath: String) : PartialLinkageTestUtils.TestConfiguration {
override val testDir: File = File(testPath).absoluteFile override val testDir: File = File(testPath).absoluteFile
override val buildDir: File get() = this@AbstractJsKLibABITestCase.buildDir override val buildDir: File get() = this@AbstractJsPartialLinkageTestCase.buildDir
override val stdlibFile: File get() = File("libraries/stdlib/js-ir/build/classes/kotlin/js/main").absoluteFile override val stdlibFile: File get() = File("libraries/stdlib/js-ir/build/classes/kotlin/js/main").absoluteFile
override val testModeName = if (this@AbstractJsKLibABITestCase.useIncrementalCompiler) "JS_WITH_IC" else "JS_NO_IC" override val testModeName = if (this@AbstractJsPartialLinkageTestCase.useIncrementalCompiler) "JS_WITH_IC" else "JS_NO_IC"
override fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: KlibABITestUtils.Dependencies, klibFile: File) = override fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: PartialLinkageTestUtils.Dependencies, klibFile: File) =
this@AbstractJsKLibABITestCase.buildKlib(moduleName, moduleSourceDir, dependencies, klibFile) this@AbstractJsPartialLinkageTestCase.buildKlib(moduleName, moduleSourceDir, dependencies, klibFile)
override fun buildBinaryAndRun(mainModuleKlibFile: File, dependencies: KlibABITestUtils.Dependencies) = override fun buildBinaryAndRun(mainModuleKlibFile: File, dependencies: PartialLinkageTestUtils.Dependencies) =
this@AbstractJsKLibABITestCase.buildBinaryAndRun(mainModuleKlibFile, dependencies) this@AbstractJsPartialLinkageTestCase.buildBinaryAndRun(mainModuleKlibFile, dependencies)
override fun onNonEmptyBuildDirectory(directory: File) { override fun onNonEmptyBuildDirectory(directory: File) {
zipAccessor.reset() zipAccessor.reset()
@@ -109,9 +109,9 @@ abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() {
} }
// The entry point to generated test classes. // The entry point to generated test classes.
fun doTest(testPath: String) = KlibABITestUtils.runTest(JsTestConfiguration(testPath)) fun doTest(testPath: String) = PartialLinkageTestUtils.runTest(JsTestConfiguration(testPath))
private fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: KlibABITestUtils.Dependencies, klibFile: File) { private fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: PartialLinkageTestUtils.Dependencies, klibFile: File) {
val config = createConfig(moduleName) val config = createConfig(moduleName)
val ktFiles = environment.createPsiFiles(moduleSourceDir) val ktFiles = environment.createPsiFiles(moduleSourceDir)
@@ -157,7 +157,7 @@ abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() {
} }
} }
private fun buildBinaryAndRun(mainModuleKlibFile: File, allDependencies: KlibABITestUtils.Dependencies) { private fun buildBinaryAndRun(mainModuleKlibFile: File, allDependencies: PartialLinkageTestUtils.Dependencies) {
val configuration = createConfig(MAIN_MODULE_NAME) val configuration = createConfig(MAIN_MODULE_NAME)
val compilationOutputs = if (useIncrementalCompiler) val compilationOutputs = if (useIncrementalCompiler)
@@ -176,7 +176,7 @@ abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() {
private fun buildBinaryWithIC( private fun buildBinaryWithIC(
configuration: CompilerConfiguration, configuration: CompilerConfiguration,
mainModuleKlibFile: File, mainModuleKlibFile: File,
allDependencies: KlibABITestUtils.Dependencies allDependencies: PartialLinkageTestUtils.Dependencies
): CompilationOutputs { ): CompilationOutputs {
// TODO: what about friend dependencies? // TODO: what about friend dependencies?
val cacheUpdater = CacheUpdater( val cacheUpdater = CacheUpdater(
@@ -208,7 +208,7 @@ abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() {
private fun buildBinaryNoIC( private fun buildBinaryNoIC(
configuration: CompilerConfiguration, configuration: CompilerConfiguration,
mainModuleKlibFile: File, mainModuleKlibFile: File,
allDependencies: KlibABITestUtils.Dependencies allDependencies: PartialLinkageTestUtils.Dependencies
): CompilationOutputs { ): CompilationOutputs {
val klib = MainModule.Klib(mainModuleKlibFile.path) val klib = MainModule.Klib(mainModuleKlibFile.path)
val moduleStructure = ModulesStructure( val moduleStructure = ModulesStructure(
@@ -21,7 +21,7 @@ import java.util.regex.Pattern;
@TestMetadata("compiler/testData/klibABI") @TestMetadata("compiler/testData/klibABI")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class) @RunWith(JUnit3RunnerWithInners.class)
public class JsKLibABINoICTestCaseGenerated extends AbstractJsKLibABINoICTestCase { public class JsPartialLinkageNoICTestCaseGenerated extends AbstractJsPartialLinkageNoICTestCase {
private void runTest(String testDataFilePath) throws Exception { private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath); KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath);
} }
@@ -21,7 +21,7 @@ import java.util.regex.Pattern;
@TestMetadata("compiler/testData/klibABI") @TestMetadata("compiler/testData/klibABI")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class) @RunWith(JUnit3RunnerWithInners.class)
public class JsKLibABIWithICTestCaseGenerated extends AbstractJsKLibABIWithICTestCase { public class JsPartialLinkageWithICTestCaseGenerated extends AbstractJsPartialLinkageWithICTestCase {
private void runTest(String testDataFilePath) throws Exception { private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath); KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath);
} }
+1 -1
View File
@@ -52,7 +52,7 @@ val stdlibTest = nativeTest("stdlibTest", "stdlib")
val stdlibK2Test = nativeTest("stdlibK2Test", "stdlibK2") val stdlibK2Test = nativeTest("stdlibK2Test", "stdlibK2")
val kotlinTestLibraryTest = nativeTest("kotlinTestLibraryTest", "kotlin-test") val kotlinTestLibraryTest = nativeTest("kotlinTestLibraryTest", "kotlin-test")
val kotlinTestK2LibraryTest = nativeTest("kotlinTestK2LibraryTest", "kotlin-testK2") val kotlinTestK2LibraryTest = nativeTest("kotlinTestK2LibraryTest", "kotlin-testK2")
val klibAbiTest = nativeTest("klibAbiTest", "klib-abi") val partialLinkageTest = nativeTest("partialLinkageTest", "partial-linkage")
val klibBinaryCompatibilityTest = nativeTest("klibBinaryCompatibilityTest", "klib-binary-compatibility") val klibBinaryCompatibilityTest = nativeTest("klibBinaryCompatibilityTest", "klib-binary-compatibility")
val cinteropTest = nativeTest("cinteropTest", "cinterop") val cinteropTest = nativeTest("cinteropTest", "cinterop")
val debuggerTest = nativeTest("debuggerTest", "debugger") val debuggerTest = nativeTest("debuggerTest", "debugger")
@@ -20,7 +20,7 @@ import java.util.regex.Pattern;
@TestMetadata("compiler/testData/klibABI") @TestMetadata("compiler/testData/klibABI")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
@FirPipeline() @FirPipeline()
public class FirKlibABITestGenerated extends AbstractNativeKlibABITest { public class FirNativePartialLinkageTestGenerated extends AbstractNativePartialLinkageTest {
@Test @Test
@TestMetadata("addEnumEntry") @TestMetadata("addEnumEntry")
public void testAddEnumEntry() throws Exception { public void testAddEnumEntry() throws Exception {
@@ -18,7 +18,7 @@ import java.util.regex.Pattern;
@SuppressWarnings("all") @SuppressWarnings("all")
@TestMetadata("compiler/testData/klibABI") @TestMetadata("compiler/testData/klibABI")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
public class K1KlibABITestGenerated extends AbstractNativeKlibABITest { public class K1NativePartialLinkageTestGenerated extends AbstractNativePartialLinkageTest {
@Test @Test
@TestMetadata("addEnumEntry") @TestMetadata("addEnumEntry")
public void testAddEnumEntry() throws Exception { public void testAddEnumEntry() throws Exception {
@@ -53,15 +53,15 @@ fun main() {
} }
} }
// KLIB ABI tests. // Partial linkage tests.
testGroup("native/native.tests/tests-gen", "compiler/testData") { testGroup("native/native.tests/tests-gen", "compiler/testData") {
testClass<AbstractNativeKlibABITest>( testClass<AbstractNativePartialLinkageTest>(
suiteTestClassName = "K1KlibABITestGenerated" suiteTestClassName = "K1NativePartialLinkageTestGenerated"
) { ) {
model("klibABI/", pattern = "^([^_](.+))$", recursive = false) model("klibABI/", pattern = "^([^_](.+))$", recursive = false)
} }
testClass<AbstractNativeKlibABITest>( testClass<AbstractNativePartialLinkageTest>(
suiteTestClassName = "FirKlibABITestGenerated", suiteTestClassName = "FirNativePartialLinkageTestGenerated",
annotations = listOf(provider<FirPipeline>()) annotations = listOf(provider<FirPipeline>())
) { ) {
model("klibABI/", pattern = "^([^_](.+))$", recursive = false) model("klibABI/", pattern = "^([^_](.+))$", recursive = false)
@@ -28,7 +28,6 @@ import kotlin.math.max
import org.jetbrains.kotlin.compatibility.binary.TestFile as BinaryCompatibilityTestFile import org.jetbrains.kotlin.compatibility.binary.TestFile as BinaryCompatibilityTestFile
import org.jetbrains.kotlin.compatibility.binary.TestModule as BinaryCompatibilityTestModule import org.jetbrains.kotlin.compatibility.binary.TestModule as BinaryCompatibilityTestModule
@Tag("klib-abi")
@Tag("klib-binary-compatibility") @Tag("klib-binary-compatibility")
abstract class AbstractNativeKlibBinaryCompatibilityTest : AbstractNativeSimpleTest() { abstract class AbstractNativeKlibBinaryCompatibilityTest : AbstractNativeSimpleTest() {
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.konan.blackboxtest
import com.intellij.testFramework.TestDataFile import com.intellij.testFramework.TestDataFile
import org.jetbrains.kotlin.codegen.ProjectInfo import org.jetbrains.kotlin.codegen.ProjectInfo
import org.jetbrains.kotlin.klib.KlibABITestUtils import org.jetbrains.kotlin.klib.PartialLinkageTestUtils
import org.jetbrains.kotlin.klib.KlibABITestUtils.Dependencies import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.Dependencies
import org.jetbrains.kotlin.klib.KlibABITestUtils.MAIN_MODULE_NAME import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.MAIN_MODULE_NAME
import org.jetbrains.kotlin.konan.blackboxtest.support.* import org.jetbrains.kotlin.konan.blackboxtest.support.*
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.WithTestRunnerExtras import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.WithTestRunnerExtras
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.* import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.*
@@ -24,12 +24,12 @@ import org.junit.jupiter.api.Tag
import org.opentest4j.TestAbortedException import org.opentest4j.TestAbortedException
import java.io.File import java.io.File
@Tag("klib-abi") @Tag("partial-linkage")
abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() { abstract class AbstractNativePartialLinkageTest : AbstractNativeSimpleTest() {
private inner class NativeTestConfiguration(testPath: String) : KlibABITestUtils.TestConfiguration { private inner class NativeTestConfiguration(testPath: String) : PartialLinkageTestUtils.TestConfiguration {
override val testDir = getAbsoluteFile(testPath) override val testDir = getAbsoluteFile(testPath)
override val buildDir get() = this@AbstractNativeKlibABITest.buildDir override val buildDir get() = this@AbstractNativePartialLinkageTest.buildDir
override val stdlibFile get() = this@AbstractNativeKlibABITest.stdlibFile override val stdlibFile get() = this@AbstractNativePartialLinkageTest.stdlibFile
override val testModeName = with(testRunSettings.get<CacheMode>()) { override val testModeName = with(testRunSettings.get<CacheMode>()) {
val cacheModeAlias = when { val cacheModeAlias = when {
@@ -47,10 +47,10 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() {
} }
override fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: Dependencies, klibFile: File) = override fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: Dependencies, klibFile: File) =
this@AbstractNativeKlibABITest.buildKlib(moduleName, moduleSourceDir, dependencies, klibFile) this@AbstractNativePartialLinkageTest.buildKlib(moduleName, moduleSourceDir, dependencies, klibFile)
override fun buildBinaryAndRun(mainModuleKlibFile: File, dependencies: Dependencies) = override fun buildBinaryAndRun(mainModuleKlibFile: File, dependencies: Dependencies) =
this@AbstractNativeKlibABITest.buildBinaryAndRun(dependencies) this@AbstractNativePartialLinkageTest.buildBinaryAndRun(dependencies)
override fun onNonEmptyBuildDirectory(directory: File) = backupDirectoryContents(directory) override fun onNonEmptyBuildDirectory(directory: File) = backupDirectoryContents(directory)
@@ -70,13 +70,13 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() {
private val producedKlibs = linkedSetOf<ProducedKlib>() // IMPORTANT: The order makes sense! private val producedKlibs = linkedSetOf<ProducedKlib>() // IMPORTANT: The order makes sense!
private val executableArtifact: Executable by lazy { private val executableArtifact: Executable by lazy {
val (_, outputDir) = KlibABITestUtils.createModuleDirs(buildDir, LAUNCHER_MODULE_NAME) val (_, outputDir) = PartialLinkageTestUtils.createModuleDirs(buildDir, LAUNCHER_MODULE_NAME)
val executableFile = outputDir.resolve("app." + testRunSettings.get<KotlinNativeTargets>().testTarget.family.exeSuffix) val executableFile = outputDir.resolve("app." + testRunSettings.get<KotlinNativeTargets>().testTarget.family.exeSuffix)
Executable(executableFile) Executable(executableFile)
} }
// The entry point to generated test classes. // The entry point to generated test classes.
protected fun runTest(@TestDataFile testPath: String) = KlibABITestUtils.runTest(NativeTestConfiguration(testPath)) protected fun runTest(@TestDataFile testPath: String) = PartialLinkageTestUtils.runTest(NativeTestConfiguration(testPath))
private fun customizeMainModuleSources(moduleSourceDir: File) { private fun customizeMainModuleSources(moduleSourceDir: File) {
// Add a "box" function launcher to the main module. // Add a "box" function launcher to the main module.
@@ -153,7 +153,7 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() {
TestModule.Exclusive( TestModule.Exclusive(
name = moduleName, name = moduleName,
directDependencySymbols = emptySet(), /* Don't need to pass any dependency symbols here. directDependencySymbols = emptySet(), /* Don't need to pass any dependency symbols here.
Dependencies are already handled by the AbstractKlibABITestCase class. */ Dependencies are already handled by the AbstractNativePartialLinkageTest class. */
directFriendSymbols = emptySet(), directFriendSymbols = emptySet(),
directDependsOnSymbols = emptySet(), directDependsOnSymbols = emptySet(),
).also { module -> ).also { module ->