[Tests] FIR support in JUnit 3 tests, port necessary subclasses
^KT-64404 Fixed ^KT-64438 Fixed ^KT-64407 Fixed
This commit is contained in:
committed by
Space Team
parent
e69d6d2d05
commit
9a2e4c6b41
-1
@@ -53,7 +53,6 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
|
||||
val configuration = createConfiguration(
|
||||
extractConfigurationKind(files),
|
||||
getTestJdkKind(files),
|
||||
backend,
|
||||
if (additionalClasspath == null) defaultClasspath else defaultClasspath + additionalClasspath,
|
||||
if (isJavaSourceRootNeeded()) listOf(javaFilesDir) else emptyList(),
|
||||
files
|
||||
|
||||
+2
-1
@@ -24,5 +24,6 @@ import org.jetbrains.kotlin.test.TargetBackend
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractIrKapt3BuilderModeBytecodeShapeTest : AbstractKapt3BuilderModeBytecodeShapeTest() {
|
||||
override val backend: TargetBackend = TargetBackend.JVM_IR
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
override val backend: TargetBackend
|
||||
final override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
|
||||
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
|
||||
@@ -71,7 +71,7 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
||||
|
||||
configurationKind = extractConfigurationKind(files)
|
||||
val configuration = createConfiguration(
|
||||
configurationKind, getTestJdkKind(files), backend, listOf(getAnnotationsJar()), listOfNotNull(writeJavaFiles(files)), files
|
||||
configurationKind, getTestJdkKind(files), listOf(getAnnotationsJar()), listOfNotNull(writeJavaFiles(files)), files
|
||||
)
|
||||
val environment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
AnalysisHandlerExtension.registerExtension(environment.project, PartialAnalysisHandlerExtension())
|
||||
|
||||
@@ -89,7 +89,6 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
|
||||
CompilerConfiguration configuration = createConfiguration(
|
||||
configurationKind,
|
||||
testJdkKind,
|
||||
getBackend(),
|
||||
Collections.singletonList(getAnnotationsJar()),
|
||||
ArraysKt.filterNotNull(javaSourceRoots),
|
||||
testFilesWithConfigurationDirectives
|
||||
@@ -379,6 +378,7 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
|
||||
@Override
|
||||
protected void updateConfiguration(@NotNull CompilerConfiguration configuration) {
|
||||
setCustomDefaultJvmTarget(configuration);
|
||||
configureIrFir(configuration);
|
||||
}
|
||||
|
||||
protected ClassBuilderFactory getClassBuilderFactory() {
|
||||
@@ -414,7 +414,7 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
|
||||
configurationKind = extractConfigurationKind(files);
|
||||
|
||||
CompilerConfiguration configuration = createConfiguration(
|
||||
configurationKind, getTestJdkKind(files), getBackend(),
|
||||
configurationKind, getTestJdkKind(files),
|
||||
Collections.singletonList(getAnnotationsJar()),
|
||||
ArraysKt.filterNotNull(new File[] {javaSourceDir}),
|
||||
files
|
||||
@@ -508,7 +508,7 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected TargetBackend getBackend() {
|
||||
public TargetBackend getBackend() {
|
||||
return TargetBackend.JVM;
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -28,7 +28,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
import java.io.File;
|
||||
|
||||
// TODO Remove this class once general multi-module bytecode text tests are implemented.
|
||||
abstract public class AbstractGenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getPrefix() {
|
||||
@@ -101,4 +101,8 @@ abstract public class AbstractGenerateNotNullAssertionsTest extends CodegenTestC
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
public void testNoAssertionsForKotlinFromBinary() {
|
||||
doTestNoAssertionsForKotlinFromBinary("noAssertionsForKotlin.kt", "noAssertionsForKotlinMain.kt");
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.codegen.fir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ir.AbstractIrWriteFlagsTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
abstract class AbstractFirLightTreeWriteFlagsTest : AbstractIrWriteFlagsTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.LightTree
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.codegen.fir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ir.AbstractIrWriteSignatureTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
abstract class AbstractFirLightTreeWriteSignatureTest : AbstractIrWriteSignatureTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.LightTree
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.codegen.fir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ir.AbstractIrWriteFlagsTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
abstract class AbstractFirPsiWriteFlagsTest : AbstractIrWriteFlagsTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.Psi
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.codegen.fir
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ir.AbstractIrWriteSignatureTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
abstract class AbstractFirPsiWriteSignatureTest : AbstractIrWriteSignatureTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.Psi
|
||||
}
|
||||
+2
-1
@@ -12,7 +12,8 @@ import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
@OptIn(ObsoleteTestInfrastructure::class)
|
||||
abstract class AbstractComposeLikeIrBlackBoxCodegenTest : AbstractBlackBoxCodegenTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
override val backend
|
||||
get() = TargetBackend.JVM_IR
|
||||
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
|
||||
ComposeLikeExtensionRegistrar.registerComponents(environment.project)
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@ import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
@OptIn(ObsoleteTestInfrastructure::class)
|
||||
abstract class AbstractComposeLikeIrBytecodeTextTest : AbstractBytecodeTextTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
override val backend
|
||||
get() = TargetBackend.JVM_IR
|
||||
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
|
||||
ComposeLikeExtensionRegistrar.registerComponents(environment.project)
|
||||
|
||||
+2
-1
@@ -9,5 +9,6 @@ import org.jetbrains.kotlin.codegen.AbstractCheckLocalVariablesTableTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrCheckLocalVariablesTableTest : AbstractCheckLocalVariablesTableTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
+2
-1
@@ -9,5 +9,6 @@ import org.jetbrains.kotlin.codegen.AbstractScriptCodegenTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrScriptCodegenTest : AbstractScriptCodegenTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
override val backend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
+2
-1
@@ -9,5 +9,6 @@ import org.jetbrains.kotlin.codegen.flags.AbstractWriteFlagsTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrWriteFlagsTest : AbstractWriteFlagsTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
override val backend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
+2
-1
@@ -9,5 +9,6 @@ import org.jetbrains.kotlin.jvm.compiler.AbstractWriteSignatureTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrWriteSignatureTest : AbstractWriteSignatureTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
override val backend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ abstract class AbstractIrGeneratorTestCase : CodegenTestCase() {
|
||||
}
|
||||
|
||||
val configuration = createConfiguration(
|
||||
configurationKind, jdkKind, backend,
|
||||
configurationKind, jdkKind,
|
||||
listOf<File>(getAnnotationsJar()),
|
||||
listOfNotNull(writeJavaFiles(files)),
|
||||
files
|
||||
|
||||
+8
-2
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils.createEnvironmentWithMockJdkAnd
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils.newConfiguration
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.testFramework.FrontendBackendConfiguration
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparatorAdaptor.validateAndCompareDescriptorWithFile
|
||||
import org.junit.Assert
|
||||
@@ -45,7 +46,7 @@ import java.io.File
|
||||
import java.io.IOException
|
||||
import java.lang.annotation.Retention
|
||||
|
||||
abstract class AbstractCompileJavaAgainstKotlinTest : TestCaseWithTmpdir() {
|
||||
abstract class AbstractCompileJavaAgainstKotlinTest : TestCaseWithTmpdir(), FrontendBackendConfiguration {
|
||||
|
||||
protected fun doTestWithJavac(ktFilePath: String) {
|
||||
doTest(ktFilePath, true)
|
||||
@@ -64,6 +65,9 @@ abstract class AbstractCompileJavaAgainstKotlinTest : TestCaseWithTmpdir() {
|
||||
|
||||
val out = File(tmpdir, "out")
|
||||
|
||||
val directives = KotlinTestUtils.parseDirectives(ktFile.readText())
|
||||
if (useFir && directives.contains("IGNORE_FIR")) return
|
||||
|
||||
val compiledSuccessfully = if (useJavac) {
|
||||
compileKotlinWithJava(
|
||||
listOf(javaFile),
|
||||
@@ -95,7 +99,9 @@ abstract class AbstractCompileJavaAgainstKotlinTest : TestCaseWithTmpdir() {
|
||||
validateAndCompareDescriptorWithFile(packageView, CONFIGURATION, expectedFile)
|
||||
}
|
||||
|
||||
open fun updateConfiguration(configuration: CompilerConfiguration) {}
|
||||
fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
configureIrFir(configuration)
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun compileKotlinWithJava(
|
||||
|
||||
+5
-2
@@ -37,13 +37,14 @@ import org.jetbrains.kotlin.test.KotlinTestUtils.createEnvironmentWithMockJdkAnd
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils.newConfiguration
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.testFramework.FrontendBackendConfiguration
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparatorAdaptor.validateAndCompareDescriptorWithFile
|
||||
import org.junit.Assert
|
||||
import java.io.File
|
||||
import java.lang.annotation.Retention
|
||||
|
||||
abstract class AbstractCompileKotlinAgainstJavaTest : TestCaseWithTmpdir() {
|
||||
abstract class AbstractCompileKotlinAgainstJavaTest : TestCaseWithTmpdir(), FrontendBackendConfiguration {
|
||||
|
||||
protected fun doTestWithoutAPT(ktFilePath: String) {
|
||||
doTest(ktFilePath, aptMode = false)
|
||||
@@ -125,7 +126,9 @@ abstract class AbstractCompileKotlinAgainstJavaTest : TestCaseWithTmpdir() {
|
||||
return JavacWrapper.getInstance(environment.project).use { it.compile(outDir) }
|
||||
}
|
||||
|
||||
open fun updateConfiguration(configuration: CompilerConfiguration) {}
|
||||
open fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
configureIrFir(configuration)
|
||||
}
|
||||
|
||||
companion object {
|
||||
// Do not render parameter names because there are test cases where classes inherit from JDK collections,
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.jvm.compiler
|
||||
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractFirCompileJavaAgainstKotlinTest(private val useLightTree: Boolean) : AbstractCompileJavaAgainstKotlinTest() {
|
||||
override fun doTest(ktFilePath: String, useJavac: Boolean) {
|
||||
val ktFile = File(ktFilePath)
|
||||
val directives = KotlinTestUtils.parseDirectives(ktFile.readText())
|
||||
if (directives.contains("IGNORE_FIR")) return
|
||||
super.doTest(ktFilePath, useJavac)
|
||||
}
|
||||
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
configuration.put(JVMConfigurationKeys.IR, true)
|
||||
configuration.put(CommonConfigurationKeys.USE_FIR, true)
|
||||
if (useLightTree) configuration.put(CommonConfigurationKeys.USE_LIGHT_TREE, true)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -217,7 +217,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
|
||||
protected void configureEnvironment(KotlinCoreEnvironment environment) {}
|
||||
|
||||
protected void updateConfiguration(CompilerConfiguration configuration) {}
|
||||
public void updateConfiguration(@NotNull CompilerConfiguration configuration) {}
|
||||
|
||||
protected void doTestJavaAgainstKotlin(String expectedFileName) {
|
||||
try {
|
||||
|
||||
+8
-1
@@ -16,10 +16,17 @@
|
||||
|
||||
package org.jetbrains.kotlin.jvm.compiler
|
||||
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.testFramework.FrontendBackendConfiguration
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractLoadJavaWithPsiClassReadingTest : AbstractLoadJavaTest() {
|
||||
abstract class AbstractLoadJavaWithPsiClassReadingTest : AbstractLoadJavaTest(), FrontendBackendConfiguration {
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
configureIrFir(configuration)
|
||||
super.updateConfiguration(configuration)
|
||||
}
|
||||
|
||||
override fun usePsiClassFilesReading() = true
|
||||
|
||||
override fun getExpectedFile(expectedFileName: String): File {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.jvm.compiler.fir
|
||||
|
||||
import org.jetbrains.kotlin.jvm.compiler.ir.AbstractIrCompileJavaAgainstKotlinTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
abstract class AbstractFirLightTreeCompileJavaAgainstKotlinTest : AbstractIrCompileJavaAgainstKotlinTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.LightTree
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.jvm.compiler.fir
|
||||
|
||||
import org.jetbrains.kotlin.jvm.compiler.ir.AbstractIrCompileJavaAgainstKotlinTest
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
|
||||
abstract class AbstractFirPsiCompileJavaAgainstKotlinTest : AbstractIrCompileJavaAgainstKotlinTest() {
|
||||
override val useFir: Boolean
|
||||
get() = true
|
||||
|
||||
override val firParser: FirParser
|
||||
get() = FirParser.Psi
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.jvm.compiler.ir
|
||||
|
||||
import org.jetbrains.kotlin.jvm.compiler.AbstractFirCompileJavaAgainstKotlinTest
|
||||
|
||||
abstract class AbstractFirLightTreeCompileJavaAgainstKotlinTest : AbstractFirCompileJavaAgainstKotlinTest(true)
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.jvm.compiler.ir
|
||||
|
||||
import org.jetbrains.kotlin.jvm.compiler.AbstractFirCompileJavaAgainstKotlinTest
|
||||
|
||||
abstract class AbstractFirPsiCompileJavaAgainstKotlinTest : AbstractFirCompileJavaAgainstKotlinTest(false)
|
||||
+3
-3
@@ -5,10 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.jvm.compiler.ir
|
||||
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.jvm.compiler.AbstractCompileJavaAgainstKotlinTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrCompileJavaAgainstKotlinTest : AbstractCompileJavaAgainstKotlinTest() {
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) = configuration.put(JVMConfigurationKeys.IR, true)
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,10 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.jvm.compiler.ir
|
||||
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.jvm.compiler.AbstractCompileKotlinAgainstJavaTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrCompileKotlinAgainstJavaTest : AbstractCompileKotlinAgainstJavaTest() {
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) = configuration.put(JVMConfigurationKeys.IR, true)
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,10 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.jvm.compiler.ir
|
||||
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.jvm.compiler.AbstractLoadJavaWithPsiClassReadingTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrLoadJavaTest : AbstractLoadJavaWithPsiClassReadingTest() {
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) = configuration.put(JVMConfigurationKeys.IR, true)
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ abstract class AbstractKlibIrTextTestCase : CodegenTestCase() {
|
||||
|
||||
private fun setupEnvironment(files: List<TestFile>) {
|
||||
val configuration = createConfiguration(
|
||||
ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, backend,
|
||||
ConfigurationKind.ALL, TestJdkKind.MOCK_JDK,
|
||||
listOf<File>(KtTestUtil.getAnnotationsJar()),
|
||||
listOfNotNull(writeJavaFiles(files)),
|
||||
files
|
||||
|
||||
@@ -9,11 +9,12 @@ import org.jetbrains.kotlin.checkers.ENABLE_JVM_PREVIEW
|
||||
import org.jetbrains.kotlin.checkers.parseLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.test.testFramework.FrontendBackendConfiguration
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
|
||||
abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase() {
|
||||
abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase(), FrontendBackendConfiguration {
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
@@ -51,26 +52,25 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
|
||||
return Companion.extractConfigurationKind(files)
|
||||
}
|
||||
|
||||
protected open fun updateConfiguration(configuration: CompilerConfiguration) {}
|
||||
protected open fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
configureIrFir(configuration)
|
||||
}
|
||||
|
||||
protected open fun setupEnvironment(environment: KotlinCoreEnvironment) {}
|
||||
|
||||
protected open fun parseDirectivesPerFiles() = false
|
||||
|
||||
protected open val backend = TargetBackend.ANY
|
||||
|
||||
protected open fun configureTestSpecific(configuration: CompilerConfiguration, testFiles: List<TestFile>) {}
|
||||
|
||||
protected fun createConfiguration(
|
||||
kind: ConfigurationKind,
|
||||
jdkKind: TestJdkKind,
|
||||
backend: TargetBackend,
|
||||
classpath: List<File?>,
|
||||
javaSource: List<File?>,
|
||||
testFilesWithConfigurationDirectives: List<TestFile>
|
||||
): CompilerConfiguration {
|
||||
val configuration = KotlinTestUtils.newConfiguration(kind, jdkKind, classpath, javaSource)
|
||||
configuration.put(JVMConfigurationKeys.IR, backend.isIR)
|
||||
updateConfigurationByDirectivesInTestFiles(
|
||||
testFilesWithConfigurationDirectives,
|
||||
configuration,
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.test.testFramework
|
||||
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
interface FrontendBackendConfiguration {
|
||||
val useFir: Boolean
|
||||
get() = false
|
||||
val firParser: FirParser
|
||||
get() = FirParser.Psi
|
||||
val backend
|
||||
get() = TargetBackend.ANY
|
||||
|
||||
fun configureIrFir(configuration: CompilerConfiguration) {
|
||||
configuration.put(JVMConfigurationKeys.IR, backend.isIR)
|
||||
configuration.put(CommonConfigurationKeys.USE_FIR, useFir)
|
||||
when (firParser) {
|
||||
FirParser.LightTree -> configuration.put(CommonConfigurationKeys.USE_LIGHT_TREE, true)
|
||||
FirParser.Psi -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user