[FIR] Create IR text tests for declarations generators

This commit is contained in:
Dmitriy Novozhilov
2021-10-01 13:51:37 +03:00
committed by TeamCityServer
parent b454fcc1e0
commit e3579389ee
17 changed files with 481 additions and 55 deletions
@@ -15,7 +15,8 @@ import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidIrBoxTest
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
import org.jetbrains.kotlin.fir.plugin.AbstractFirAllOpenDiagnosticTest
import org.jetbrains.kotlin.fir.plugin.runners.AbstractFir2IrAllOpenTest
import org.jetbrains.kotlin.fir.plugin.runners.AbstractFirAllOpenDiagnosticTest
import org.jetbrains.kotlin.generators.TestGroup
import org.jetbrains.kotlin.generators.generateTestGroupSuiteWithJUnit5
import org.jetbrains.kotlin.generators.impl.generateTestGroupSuite
@@ -373,6 +374,10 @@ fun main(args: Array<String>) {
testClass<AbstractFirAllOpenDiagnosticTest> {
model("diagnostics")
}
testClass<AbstractFir2IrAllOpenTest> {
model("fir2ir")
}
}
}
}
@@ -0,0 +1,68 @@
FILE fqName:<root> fileName:/classWithGeneratedMembersAndNestedClass.kt
CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
C
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Foo
CONSTRUCTOR visibility:public <> () returnType:<root>.Foo [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]'
CLASS CLASS name:MyNested modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Foo.MyNested
CONSTRUCTOR visibility:public <> () returnType:<root>.Foo.MyNested [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyNested modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:materialize visibility:public modality:FINAL <> () returnType:<root>.Foo [fake_override]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Bar
CONSTRUCTOR visibility:public <> () returnType:<root>.Bar [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:test_1 visibility:public modality:FINAL <> (foo:<root>.Foo) returnType:kotlin.Unit
VALUE_PARAMETER name:foo index:0 type:<root>.Foo
BLOCK_BODY
VAR name:foo2 type:<root>.Foo [val]
CALL 'public final fun materialize (): <root>.Foo declared in <root>' type=<root>.Foo origin=null
VAR name:nested type:<root>.Foo.Nested [val]
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Foo.Nested' type=<root>.Foo.Nested origin=null
@@ -0,0 +1,29 @@
FILE: classWithGeneratedMembersAndNestedClass.kt
@R|org/jetbrains/kotlin/fir/plugin/C|() public final class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
super<R|kotlin/Any|>()
}
public final class MyNested : R|kotlin/Any| {
public constructor(): R|Foo.MyNested| {
super<R|kotlin/Any|>()
}
}
public final fun materialize(): R|Foo|
public final class Nested : R|kotlin/Any| {
}
}
public final class Bar : R|kotlin/Any| {
public constructor(): R|Bar| {
super<R|kotlin/Any|>()
}
}
public final fun test_1(foo: R|Foo|): R|kotlin/Unit| {
lval foo2: R|Foo| = R|<local>/foo|.R|/Foo.materialize|()
lval nested: R|Foo.Nested| = Q|Foo|.R|/Foo.Nested|()
}
@@ -0,0 +1,13 @@
import org.jetbrains.kotlin.fir.plugin.C
@C
class Foo {
class MyNested
}
class Bar
fun test_1(foo: Foo) {
val foo2: Foo = foo.materialize()
val nested = Foo.Nested()
}
@@ -0,0 +1,63 @@
FILE fqName:bar fileName:/generatedClassWithMembersAndNestedClasses.kt
CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
B
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:bar.Foo
CONSTRUCTOR visibility:public <> () returnType:bar.Foo [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN name:foo visibility:public modality:FINAL <> ($this:bar.Foo) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:bar.Foo
BLOCK_BODY
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
B
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:bar.Bar
CONSTRUCTOR visibility:public <> () returnType:bar.Bar [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN name:bar visibility:public modality:FINAL <> ($this:bar.Bar) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:bar.Bar
BLOCK_BODY
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:testConstructor visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:generatedClass type:foo.AllOpenGenerated [val]
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in foo.AllOpenGenerated' type=foo.AllOpenGenerated origin=null
FUN name:testNestedClasses visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:nestedFoo type:foo.AllOpenGenerated.NestedFoo [val]
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in foo.AllOpenGenerated.NestedFoo' type=foo.AllOpenGenerated.NestedFoo origin=null
CALL 'public final fun foo (): kotlin.Unit declared in bar.Foo' type=kotlin.Unit origin=null
$this: CALL 'public final fun materialize (): bar.Foo declared in foo' type=bar.Foo origin=null
VAR name:nestedBar type:foo.AllOpenGenerated.NestedBar [val]
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in foo.AllOpenGenerated.NestedBar' type=foo.AllOpenGenerated.NestedBar origin=null
CALL 'public final fun bar (): kotlin.Unit declared in bar.Bar' type=kotlin.Unit origin=null
$this: CALL 'public final fun materialize (): bar.Foo declared in foo' type=bar.Bar origin=null
@@ -0,0 +1,45 @@
FILE: generatedClassWithMembersAndNestedClasses.kt
package bar
@R|org/jetbrains/kotlin/fir/plugin/B|() public final class Foo : R|kotlin/Any| {
public constructor(): R|bar/Foo| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
}
}
@R|org/jetbrains/kotlin/fir/plugin/B|() public final class Bar : R|kotlin/Any| {
public constructor(): R|bar/Bar| {
super<R|kotlin/Any|>()
}
public final fun bar(): R|kotlin/Unit| {
}
}
public final fun testConstructor(): R|kotlin/Unit| {
lval generatedClass: R|foo/AllOpenGenerated| = R|foo/AllOpenGenerated|()
}
public final fun testNestedClasses(): R|kotlin/Unit| {
lval nestedFoo: R|foo/AllOpenGenerated.NestedFoo| = Q|foo/AllOpenGenerated|.R|foo/AllOpenGenerated.NestedFoo|()
R|<local>/nestedFoo|.R|foo/AllOpenGenerated.NestedFoo.materialize|().R|bar/Foo.foo|()
lval nestedBar: R|foo/AllOpenGenerated.NestedBar| = Q|foo/AllOpenGenerated|.R|foo/AllOpenGenerated.NestedBar|()
R|<local>/nestedBar|.R|foo/AllOpenGenerated.NestedBar.materialize|().R|bar/Bar.bar|()
}
FILE: ### GENERATED DECLARATIONS ###
package foo
public final class AllOpenGenerated : R|kotlin/Any| {
public final class NestedFoo : R|kotlin/Any| {
public final fun materialize(): R|bar/Foo|
}
public final class NestedBar : R|kotlin/Any| {
public final fun materialize(): R|bar/Bar|
}
}
@@ -0,0 +1,27 @@
package bar
import foo.AllOpenGenerated
import org.jetbrains.kotlin.fir.plugin.B
@B
class Foo {
fun foo() {}
}
@B
class Bar {
fun bar() {}
}
fun testConstructor() {
val generatedClass: AllOpenGenerated = AllOpenGenerated()
}
fun testNestedClasses() {
val nestedFoo = AllOpenGenerated.NestedFoo()
nestedFoo.materialize().foo()
val nestedBar = AllOpenGenerated.NestedBar()
nestedBar.materialize().bar()
}
@@ -0,0 +1,33 @@
FILE fqName:foo fileName:/topLevelCallables.kt
CLASS CLASS name:MySuperClass modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
A
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:foo.MySuperClass
CONSTRUCTOR visibility:public <> () returnType:foo.MySuperClass [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MySuperClass modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN name:test visibility:public modality:FINAL <> ($this:foo.MySuperClass) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:foo.MySuperClass
BLOCK_BODY
VAR name:s type:kotlin.String [val]
CALL 'public final fun dummyMySuperClass (value: foo.MySuperClass): kotlin.String declared in foo' type=kotlin.String origin=null
value: GET_VAR '<this>: foo.MySuperClass declared in foo.MySuperClass.test' type=foo.MySuperClass origin=null
CALL 'public final fun takeString (s: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=null
s: GET_VAR 'val s: kotlin.String [val] declared in foo.MySuperClass.test' type=kotlin.String origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:takeString visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit
VALUE_PARAMETER name:s index:0 type:kotlin.String
BLOCK_BODY
@@ -0,0 +1,20 @@
FILE: topLevelCallables.kt
package foo
@R|org/jetbrains/kotlin/fir/plugin/A|() public final class MySuperClass : R|kotlin/Any| {
public constructor(): R|foo/MySuperClass| {
super<R|kotlin/Any|>()
}
public final fun test(): R|kotlin/Unit| {
lval s: R|kotlin/String| = R|foo/dummyMySuperClass|(this@R|foo/MySuperClass|)
R|foo/takeString|(R|<local>/s|)
}
}
public final fun takeString(s: R|kotlin/String|): R|kotlin/Unit| {
}
FILE: ### GENERATED DECLARATIONS ###
package foo
public final fun dummyMySuperClass(value: R|foo/MySuperClass|): R|kotlin/String|
@@ -0,0 +1,13 @@
package foo
import org.jetbrains.kotlin.fir.plugin.A
@A
class MySuperClass {
fun test() {
val s = dummyMySuperClass(this)
takeString(s)
}
}
fun takeString(s: String) {}
@@ -0,0 +1,55 @@
/*
* Copyright 2010-2021 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.fir.plugin.runners;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
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 GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/fir/fir-plugin-prototype/testData/fir2ir")
@TestDataPath("$PROJECT_ROOT")
public class Fir2IrAllOpenTestGenerated extends AbstractFir2IrAllOpenTest {
@Test
public void testAllFilesPresentInFir2ir() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData/fir2ir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Nested
@TestMetadata("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen")
@TestDataPath("$PROJECT_ROOT")
public class MemberGen {
@Test
public void testAllFilesPresentInMemberGen() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("classWithGeneratedMembersAndNestedClass.kt")
public void testClassWithGeneratedMembersAndNestedClass() throws Exception {
runTest("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.kt");
}
@Test
@TestMetadata("generatedClassWithMembersAndNestedClasses.kt")
public void testGeneratedClassWithMembersAndNestedClasses() throws Exception {
runTest("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.kt");
}
@Test
@TestMetadata("topLevelCallables.kt")
public void testTopLevelCallables() throws Exception {
runTest("plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.kt");
}
}
}
@@ -3,7 +3,7 @@
* 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.fir.plugin;
package org.jetbrains.kotlin.fir.plugin.runners;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
@@ -1,53 +0,0 @@
/*
* Copyright 2010-2020 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.fir.plugin
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.test.Constructor
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.ENABLE_PLUGIN_PHASES
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_DUMP
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
import org.jetbrains.kotlin.test.services.EnvironmentConfigurator
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions
import java.io.File
abstract class AbstractFirAllOpenDiagnosticTest : AbstractKotlinCompilerTest() {
override fun TestConfigurationBuilder.configuration() {
baseFirDiagnosticTestConfiguration(frontendFacade = facade)
defaultDirectives {
+ENABLE_PLUGIN_PHASES
+FIR_DUMP
}
useConfigurators(::PluginAnnotationsProvider)
}
private val facade: Constructor<FirFrontendFacade>
get() = { testServices ->
FirFrontendFacade(testServices) {
it.registerExtensions(FirAllOpenComponentRegistrar().configure())
}
}
class PluginAnnotationsProvider(testServices: TestServices) : EnvironmentConfigurator(testServices) {
companion object {
const val ANNOTATIONS_JAR =
"plugins/fir/fir-plugin-prototype/plugin-annotations/build/libs/plugin-annotations-1.6.255-SNAPSHOT.jar"
}
override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) {
val jar = File(ANNOTATIONS_JAR)
testServices.assertions.assertTrue(jar.exists()) { "Jar with annotations does not exist. Please run :plugins:fir:fir-plugin-prototype:plugin-annotations:jar" }
configuration.addJvmClasspathRoot(jar)
}
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2010-2021 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.fir.plugin.runners
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler
import org.jetbrains.kotlin.test.backend.handlers.IrTreeVerifierHandler
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.builders.fir2IrStep
import org.jetbrains.kotlin.test.builders.irHandlersStep
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_IR
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
open class AbstractFir2IrAllOpenTest : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) {
override fun TestConfigurationBuilder.configuration() {
defaultDirectives {
+DUMP_IR
}
commonFirWithPluginFrontendConfiguration()
fir2IrStep()
irHandlersStep {
useHandlers(
::IrTextDumpHandler,
::IrTreeVerifierHandler,
)
}
}
}
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2021 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.fir.plugin.runners
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
abstract class AbstractFirAllOpenDiagnosticTest : AbstractKotlinCompilerTest() {
override fun TestConfigurationBuilder.configuration() {
commonFirWithPluginFrontendConfiguration()
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2010-2021 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.fir.plugin.runners
import org.jetbrains.kotlin.fir.plugin.FirAllOpenComponentRegistrar
import org.jetbrains.kotlin.fir.plugin.services.PluginAnnotationsProvider
import org.jetbrains.kotlin.test.Constructor
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.ENABLE_PLUGIN_PHASES
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_DUMP
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
fun TestConfigurationBuilder.commonFirWithPluginFrontendConfiguration() {
baseFirDiagnosticTestConfiguration(frontendFacade = FirFrontendFacadeWithPlugin)
defaultDirectives {
+ENABLE_PLUGIN_PHASES
+FIR_DUMP
}
useConfigurators(::PluginAnnotationsProvider)
}
val FirFrontendFacadeWithPlugin: Constructor<FirFrontendFacade>
get() = { testServices ->
FirFrontendFacade(testServices) {
it.registerExtensions(FirAllOpenComponentRegistrar().configure())
}
}
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2021 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.fir.plugin.services
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.EnvironmentConfigurator
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions
import java.io.File
class PluginAnnotationsProvider(testServices: TestServices) : EnvironmentConfigurator(testServices) {
companion object {
const val ANNOTATIONS_JAR =
"plugins/fir/fir-plugin-prototype/plugin-annotations/build/libs/plugin-annotations-1.6.255-SNAPSHOT.jar"
}
override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) {
val jar = File(ANNOTATIONS_JAR)
testServices.assertions.assertTrue(jar.exists()) { "Jar with annotations does not exist. Please run :plugins:fir:fir-plugin-prototype:plugin-annotations:jar" }
configuration.addJvmClasspathRoot(jar)
}
}