Extract JVM logic of AbstractIrInterpreterTest into separate class

This commit is contained in:
Ivan Kylchik
2022-12-22 15:37:51 +01:00
committed by Space Team
parent 13cad2a820
commit 7d6bac64fb
4 changed files with 33 additions and 23 deletions
@@ -19,7 +19,7 @@ import java.util.regex.Pattern;
@SuppressWarnings("all")
@TestMetadata("compiler/testData/ir/interpreter")
@TestDataPath("$PROJECT_ROOT")
public class IrInterpreterAfterFir2IrTestGenerated extends AbstractIrInterpreterAfterFir2IrTest {
public class JvmIrInterpreterAfterFir2IrTestGenerated extends AbstractJvmIrInterpreterAfterFir2IrTest {
@Test
@TestMetadata("abstract1.kt")
public void testAbstract1() throws Exception {
@@ -19,7 +19,7 @@ import java.util.regex.Pattern;
@SuppressWarnings("all")
@TestMetadata("compiler/testData/ir/interpreter")
@TestDataPath("$PROJECT_ROOT")
public class IrInterpreterAfterPsi2IrTestGenerated extends AbstractIrInterpreterAfterPsi2IrTest {
public class JvmIrInterpreterAfterPsi2IrTestGenerated extends AbstractJvmIrInterpreterAfterPsi2IrTest {
@Test
@TestMetadata("abstract1.kt")
public void testAbstract1() throws Exception {
@@ -29,41 +29,30 @@ import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurat
import org.jetbrains.kotlin.test.services.sourceProviders.IrInterpreterHelpersSourceFilesProvider
open class AbstractIrInterpreterTest(
private val frontendKind: FrontendKind<*>
) : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) {
private val frontendKind: FrontendKind<*>, targetBackend: TargetBackend
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
override fun TestConfigurationBuilder.configuration() {
globalDefaults {
frontend = frontendKind
targetPlatform = JvmPlatforms.defaultJvmPlatform
artifactKind = BinaryKind.NoArtifact
targetBackend = TargetBackend.JVM_IR
dependencyKind = DependencyKind.Source
}
defaultDirectives {
+JvmEnvironmentConfigurationDirectives.FULL_JDK
+JvmEnvironmentConfigurationDirectives.NO_RUNTIME
+LanguageSettingsDirectives.ALLOW_KOTLIN_PACKAGE
}
useConfigurators(
::CommonEnvironmentConfigurator,
::IrInterpreterEnvironmentConfigurator,
::JvmEnvironmentConfigurator,
)
firFrontendStep()
classicFrontendStep()
fir2IrStep()
psi2IrStep()
jvmIrBackendStep()
irHandlersStep {
useHandlers(::IrInterpreterBackendHandler)
}
useAdditionalSourceProviders(::IrInterpreterHelpersSourceFilesProvider)
useSourcePreprocessor(::IrInterpreterImplicitKotlinImports)
jvmIrBackendStep()
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
@@ -71,8 +60,29 @@ open class AbstractIrInterpreterTest(
}
}
open class AbstractIrInterpreterAfterFir2IrTest : AbstractIrInterpreterTest(FrontendKinds.FIR)
open class AbstractIrInterpreterAfterPsi2IrTest : AbstractIrInterpreterTest(FrontendKinds.ClassicFrontend)
open class AbstractJvmIrInterpreterTest(frontendKind: FrontendKind<*>) : AbstractIrInterpreterTest(frontendKind, TargetBackend.JVM_IR) {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
with(builder) {
globalDefaults {
targetPlatform = JvmPlatforms.defaultJvmPlatform
}
defaultDirectives {
+JvmEnvironmentConfigurationDirectives.FULL_JDK
+JvmEnvironmentConfigurationDirectives.NO_RUNTIME
+LanguageSettingsDirectives.ALLOW_KOTLIN_PACKAGE
}
useConfigurators(::JvmEnvironmentConfigurator)
useAdditionalSourceProviders(::IrInterpreterHelpersSourceFilesProvider)
useSourcePreprocessor(::IrInterpreterImplicitKotlinImports)
}
}
}
open class AbstractJvmIrInterpreterAfterFir2IrTest : AbstractJvmIrInterpreterTest(FrontendKinds.FIR)
open class AbstractJvmIrInterpreterAfterPsi2IrTest : AbstractJvmIrInterpreterTest(FrontendKinds.ClassicFrontend)
class IrInterpreterEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
override fun provideAdditionalAnalysisFlags(
@@ -14,8 +14,8 @@ import org.jetbrains.kotlin.test.runners.ir.AbstractFir2IrTextTest
import org.jetbrains.kotlin.test.runners.ir.AbstractIrTextTest
import org.jetbrains.kotlin.test.runners.ir.AbstractLightTreeFir2IrTextTest
import org.jetbrains.kotlin.test.runners.ir.AbstractLoweredIrInterpreterTest
import org.jetbrains.kotlin.test.runners.ir.interpreter.AbstractIrInterpreterAfterFir2IrTest
import org.jetbrains.kotlin.test.runners.ir.interpreter.AbstractIrInterpreterAfterPsi2IrTest
import org.jetbrains.kotlin.test.runners.ir.interpreter.AbstractJvmIrInterpreterAfterFir2IrTest
import org.jetbrains.kotlin.test.runners.ir.interpreter.AbstractJvmIrInterpreterAfterPsi2IrTest
import org.jetbrains.kotlin.test.utils.CUSTOM_TEST_DATA_EXTENSION_PATTERN
import org.jetbrains.kotlin.visualizer.fir.AbstractFirVisualizerTest
import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizerTest
@@ -180,11 +180,11 @@ fun generateJUnit5CompilerTests(args: Array<String>) {
model("codegen/asmLike")
}
testClass<AbstractIrInterpreterAfterFir2IrTest> {
testClass<AbstractJvmIrInterpreterAfterFir2IrTest> {
model("ir/interpreter", excludeDirs = listOf("helpers"))
}
testClass<AbstractIrInterpreterAfterPsi2IrTest> {
testClass<AbstractJvmIrInterpreterAfterPsi2IrTest> {
model("ir/interpreter", excludeDirs = listOf("helpers"))
}
}