Add ir interpreter tests for ir built from psi

This commit is contained in:
Ivan Kylchik
2021-05-28 16:18:20 +03:00
committed by TeamCityServer
parent a9882a86c0
commit 6fe8dd1254
5 changed files with 721 additions and 5 deletions
@@ -12,13 +12,13 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
import org.jetbrains.kotlin.test.backend.handlers.IrInterpreterBackendHandler
import org.jetbrains.kotlin.test.backend.handlers.NoFirCompilationErrorsHandler
import org.jetbrains.kotlin.test.builders.*
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives
import org.jetbrains.kotlin.test.model.BinaryKind
import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.FrontendKind
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.preprocessors.IrInterpreterImplicitKotlinImports
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
@@ -28,10 +28,12 @@ import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigu
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.sourceProviders.IrInterpreterHelpersSourceFilesProvider
open class AbstractIrInterpreterAfterFir2IrTest : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) {
open class AbstractIrInterpreterTest(
private val frontendKind: FrontendKind<*>
) : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) {
override fun TestConfigurationBuilder.configuration() {
globalDefaults {
frontend = FrontendKinds.FIR
frontend = frontendKind
targetPlatform = JvmPlatforms.defaultJvmPlatform
artifactKind = BinaryKind.NoArtifact
targetBackend = TargetBackend.JVM_IR
@@ -51,13 +53,15 @@ open class AbstractIrInterpreterAfterFir2IrTest : AbstractKotlinCompilerWithTarg
)
firFrontendStep()
classicFrontendStep()
fir2IrStep()
psi2IrStep()
jvmIrBackendStep()
irHandlersStep {
useHandlers(::IrInterpreterBackendHandler)
}
useAdditionalSourceProviders(::IrInterpreterHelpersSourceFilesProvider)
useSourcePreprocessor(::IrInterpreterImplicitKotlinImports)
@@ -67,6 +71,9 @@ open class AbstractIrInterpreterAfterFir2IrTest : AbstractKotlinCompilerWithTarg
}
}
open class AbstractIrInterpreterAfterFir2IrTest : AbstractIrInterpreterTest(FrontendKinds.FIR)
open class AbstractIrInterpreterAfterPsi2IrTest : AbstractIrInterpreterTest(FrontendKinds.ClassicFrontend)
class IrInterpreterEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
override fun provideAdditionalAnalysisFlags(
directives: RegisteredDirectives,
@@ -30,6 +30,7 @@ class IrInterpreterHelpersSourceFilesProvider(testServices: TestServices) : Addi
private val ANNOTATIONS_PATHS = arrayOf(
"./libraries/stdlib/src/kotlin/annotations",
"./libraries/stdlib/src/kotlin/internal/Annotations.kt",
"./libraries/stdlib/src/kotlin/experimental/inferenceMarker.kt",
"./libraries/stdlib/jvm/runtime/kotlin/jvm/annotations/JvmPlatformAnnotations.kt",
)
private const val REFLECT_PATH = "./libraries/stdlib/jvm/src/kotlin/reflect"