[FIR] Migrate fir plugin prototype tests to new test infrastructure
This commit is contained in:
committed by
TeamCityServer
parent
e56c87a17a
commit
6d42914e56
@@ -45,7 +45,8 @@ class FirAnalyzerFacade(
|
||||
val languageVersionSettings: LanguageVersionSettings,
|
||||
val ktFiles: Collection<KtFile> = emptyList(), // may be empty if light tree mode enabled
|
||||
val originalFiles: Collection<File> = emptyList(), // may be empty if light tree mode disabled
|
||||
val useLightTree: Boolean = false
|
||||
val useLightTree: Boolean = false,
|
||||
val enablePluginPhases: Boolean = false,
|
||||
) : AbstractFirAnalyzerFacade() {
|
||||
private var firFiles: List<FirFile>? = null
|
||||
private var _scopeSession: ScopeSession? = null
|
||||
@@ -77,7 +78,7 @@ class FirAnalyzerFacade(
|
||||
override fun runResolution(): List<FirFile> {
|
||||
if (firFiles == null) buildRawFir()
|
||||
if (_scopeSession != null) return firFiles!!
|
||||
val resolveProcessor = FirTotalResolveProcessor(session)
|
||||
val resolveProcessor = FirTotalResolveProcessor(session, enablePluginPhases)
|
||||
resolveProcessor.process(firFiles!!)
|
||||
_scopeSession = resolveProcessor.scopeSession
|
||||
return firFiles!!
|
||||
|
||||
+2
-2
@@ -15,10 +15,10 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitTyp
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.contracts.FirContractResolveProcessor
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.plugin.*
|
||||
|
||||
class FirTotalResolveProcessor(session: FirSession) {
|
||||
class FirTotalResolveProcessor(session: FirSession, enablePluginPhases: Boolean = false) {
|
||||
val scopeSession: ScopeSession = ScopeSession()
|
||||
|
||||
private val processors: List<FirResolveProcessor> = createAllCompilerResolveProcessors(session, scopeSession)
|
||||
private val processors: List<FirResolveProcessor> = createAllCompilerResolveProcessors(session, scopeSession, enablePluginPhases)
|
||||
|
||||
fun process(files: List<FirFile>) {
|
||||
for (processor in processors) {
|
||||
|
||||
+4
@@ -57,4 +57,8 @@ object FirDiagnosticsDirectives : SimpleDirectivesContainer() {
|
||||
Enables ${FirScopeDumpHandler::class}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
val ENABLE_PLUGIN_PHASES by directive(
|
||||
description = "Enable plugin phases"
|
||||
)
|
||||
}
|
||||
|
||||
+18
-2
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmModularRoots
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.FirAnalyzerFacade
|
||||
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
@@ -38,8 +39,14 @@ import org.jetbrains.kotlin.test.model.*
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
|
||||
class FirFrontendFacade(
|
||||
testServices: TestServices
|
||||
testServices: TestServices,
|
||||
private val additionalSessionConfiguration: SessionConfiguration?
|
||||
) : FrontendFacade<FirOutputArtifact>(testServices, FrontendKinds.FIR) {
|
||||
// Separate constructor is needed for creating callable references to it
|
||||
constructor(testServices: TestServices) : this(testServices, additionalSessionConfiguration = null)
|
||||
|
||||
fun interface SessionConfiguration : (FirSessionFactory.FirSessionConfigurator) -> Unit
|
||||
|
||||
override val additionalServices: List<ServiceRegistrationData>
|
||||
get() = listOf(service(::FirModuleInfoProvider))
|
||||
|
||||
@@ -98,11 +105,20 @@ class FirFrontendFacade(
|
||||
if (FirDiagnosticsDirectives.WITH_EXTENDED_CHECKERS in module.directives) {
|
||||
registerExtendedCommonCheckers()
|
||||
}
|
||||
additionalSessionConfiguration?.invoke(this)
|
||||
}
|
||||
|
||||
moduleInfoProvider.registerModuleData(module, session.moduleData)
|
||||
|
||||
val firAnalyzerFacade = FirAnalyzerFacade(session, languageVersionSettings, ktFiles, originalFiles, lightTreeEnabled)
|
||||
val enablePluginPhases = FirDiagnosticsDirectives.ENABLE_PLUGIN_PHASES in module.directives
|
||||
val firAnalyzerFacade = FirAnalyzerFacade(
|
||||
session,
|
||||
languageVersionSettings,
|
||||
ktFiles,
|
||||
originalFiles,
|
||||
lightTreeEnabled,
|
||||
enablePluginPhases
|
||||
)
|
||||
val firFiles = firAnalyzerFacade.runResolution()
|
||||
val filesMap = firFiles.mapNotNull { firFile ->
|
||||
val testFile = module.files.firstOrNull { it.name == firFile.name } ?: return@mapNotNull null
|
||||
|
||||
@@ -369,7 +369,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("plugins/fir/fir-plugin-prototype/tests", "plugins/fir/fir-plugin-prototype/testData") {
|
||||
testGroup("plugins/fir/fir-plugin-prototype/tests-gen", "plugins/fir/fir-plugin-prototype/testData") {
|
||||
testClass<AbstractFirAllOpenDiagnosticTest> {
|
||||
model("")
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import org.jetbrains.kotlin.ideaExt.idea
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
@@ -8,36 +10,54 @@ dependencies {
|
||||
api(project(":compiler:fir:tree"))
|
||||
api(project(":compiler:fir:resolve"))
|
||||
api(project(":compiler:fir:checkers"))
|
||||
api(project(":compiler:frontend"))
|
||||
api(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
|
||||
compileOnly(project(":kotlin-reflect-api"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
|
||||
|
||||
testApi(intellijDep())
|
||||
|
||||
testApi(commonDep("junit:junit"))
|
||||
testCompileOnly(project(":kotlin-test:kotlin-test-jvm"))
|
||||
testCompileOnly(project(":kotlin-test:kotlin-test-junit"))
|
||||
testApi(projectTests(":compiler:tests-common"))
|
||||
testApiJUnit5()
|
||||
testApi(projectTests(":compiler:tests-common-new"))
|
||||
testApi(projectTests(":compiler:test-infrastructure"))
|
||||
testApi(projectTests(":compiler:test-infrastructure-utils"))
|
||||
testApi(project(":compiler:fir:checkers"))
|
||||
testApi(project(":compiler:fir:checkers:checkers.jvm"))
|
||||
testApi(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests"))
|
||||
testApi(project(":compiler:frontend"))
|
||||
|
||||
testCompileOnly(project(":kotlin-reflect-api"))
|
||||
testRuntimeOnly(project(":kotlin-reflect"))
|
||||
testRuntimeOnly(project(":core:descriptors.runtime"))
|
||||
|
||||
testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
testRuntimeOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
testRuntimeOnly(intellijDep()) {
|
||||
includeJars("jna", rootProject = rootProject)
|
||||
}
|
||||
|
||||
testRuntimeOnly(intellijDep()) { includeJars(
|
||||
"intellij-deps-fastutil-8.4.1-4",
|
||||
"trove4j",
|
||||
"jdom"
|
||||
) }
|
||||
testRuntimeOnly(toolsJar())
|
||||
}
|
||||
|
||||
val generationRoot = projectDir.resolve("tests-gen")
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { projectDefault() }
|
||||
"main" {
|
||||
projectDefault()
|
||||
}
|
||||
"test" {
|
||||
projectDefault()
|
||||
this.java.srcDir(generationRoot.name)
|
||||
}
|
||||
}
|
||||
|
||||
projectTest(parallel = true) {
|
||||
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
apply(plugin = "idea")
|
||||
idea {
|
||||
this.module.generatedSourceDirs.add(generationRoot)
|
||||
}
|
||||
}
|
||||
|
||||
projectTest(parallel = true, jUnit5Enabled = true) {
|
||||
workingDir = rootDir
|
||||
jvmArgs!!.removeIf { it.contains("-Xmx") }
|
||||
maxHeapSize = "3g"
|
||||
|
||||
@@ -3,6 +3,9 @@ plugins {
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(kotlinStdlib())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ FILE: functionForProperty.kt
|
||||
|
||||
}
|
||||
public final fun test_1(a: R|A|): R|kotlin/Unit| {
|
||||
R|<local>/a|.R|/A.helloX|()
|
||||
R|<local>/a|.<Unresolved name: helloX>#()
|
||||
}
|
||||
public final fun test_2(b: R|B|): R|kotlin/Unit| {
|
||||
R|<local>/b|.<Unresolved name: helloX>#()
|
||||
@@ -0,0 +1,37 @@
|
||||
FILE: nestedClass.kt
|
||||
public final fun <T> R|T|.also(block: R|(T) -> kotlin/Unit|): R|T| {
|
||||
^also this@R|/also|
|
||||
}
|
||||
@R|org/jetbrains/kotlin/fir/plugin/WithNestedFoo|() public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final fun test(): R|A.Foo| {
|
||||
^test <Resolution to classifier>#().<None of the following candidates is applicable because of receiver type mismatch: [/also]>#<R|A.Foo|>(<L> = also@fun <anonymous>(it: R|A.Foo|): R|kotlin/Unit| <inline=Unknown> {
|
||||
R|<local>/it|.<Unresolved name: hello>#()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private final inner class Foo {
|
||||
public constructor(): R|A.Foo|
|
||||
|
||||
public final fun hello(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final fun test(): <ERROR TYPE REF: Symbol not found for Foo> {
|
||||
^test <Unresolved name: Foo>#().<None of the following candidates is applicable because of receiver type mismatch: [/also]>#<R|ERROR CLASS: Cannot infer argument for type parameter T|>(<L> = also@fun <anonymous>(it: <ERROR TYPE REF: Cannot infer argument for type parameter T>): R|kotlin/Unit| <inline=Unknown> {
|
||||
R|<local>/it|.<Unresolved name: hello>#()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
FILE: nestedClass.kt
|
||||
public final fun <T> R|T|.also(block: R|(T) -> kotlin/Unit|): R|T| {
|
||||
^also this@R|/also|
|
||||
}
|
||||
@R|org/jetbrains/kotlin/fir/plugin/WithNestedFoo|() public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final fun test(): R|A.Foo| {
|
||||
^test R|/A.Foo.Foo|().R|/also|<R|A.Foo|>(<L> = also@fun <anonymous>(it: R|A.Foo|): R|kotlin/Unit| {
|
||||
^ R|<local>/it|.R|/A.Foo.hello|()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private final inner class Foo {
|
||||
public constructor(): R|A.Foo|
|
||||
|
||||
public final fun hello(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final fun test(): R|ERROR CLASS: Symbol not found, for `Foo`| {
|
||||
^test <Unresolved name: Foo>#().<Inapplicable(WRONG_RECEIVER): [/also]>#(<L> = also@fun <anonymous>(): R|ERROR CLASS: Unresolved name: hello| {
|
||||
^ <Unresolved name: it>#.<Unresolved name: hello>#()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -15,5 +15,5 @@ FILE: recursiveNestedClasses.kt
|
||||
}
|
||||
public final fun test_2(x: R|SomeClass.Nested.Nested|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test_3(x: R|ERROR CLASS: Symbol not found, for `SomeClass.Nested.Nested.Nested`|): R|kotlin/Unit| {
|
||||
public final fun test_3(x: <ERROR TYPE REF: Symbol not found for SomeClass.Nested.Nested.Nested>): R|kotlin/Unit| {
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ FILE: topLevelClass.kt
|
||||
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
Q|TopLevelSomeClass|.R|/TopLevelSomeClass.hello|()
|
||||
Q|TopLevelSomeClass|.<Unresolved name: hello>#()
|
||||
}
|
||||
public final object TopLevelSomeClass {
|
||||
public final fun hello(): R|kotlin/Int|
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
FILE: visibilityTransformation.kt
|
||||
@R|org/jetbrains/kotlin/fir/plugin/AllPublic|(visibility = Q|org/jetbrains/kotlin/fir/plugin/Visibility|.R|org/jetbrains/kotlin/fir/plugin/Visibility.Protected|) public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/String| = String()
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final class Nested : R|kotlin/Any| {
|
||||
public constructor(): R|A.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@R|org/jetbrains/kotlin/fir/plugin/AllPublic|(visibility = Q|org/jetbrains/kotlin/fir/plugin/Visibility|.R|org/jetbrains/kotlin/fir/plugin/Visibility.Private|) public final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/String| = String()
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final class Nested : R|kotlin/Any| {
|
||||
public constructor(): R|B.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
FILE: visibilityTransformation.kt
|
||||
@R|org/jetbrains/kotlin/fir/plugin/AllPublic|(Q|org/jetbrains/kotlin/fir/plugin/Visibility|.R|org/jetbrains/kotlin/fir/plugin/Visibility.Protected|) protected final class A : R|kotlin/Any| {
|
||||
protected constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
protected final val x: R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
protected final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
protected final class Nested : R|kotlin/Any| {
|
||||
protected constructor(): R|A.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
protected final fun bar(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@R|org/jetbrains/kotlin/fir/plugin/AllPublic|(Q|org/jetbrains/kotlin/fir/plugin/Visibility|.R|org/jetbrains/kotlin/fir/plugin/Visibility.Private|) private final class B : R|kotlin/Any| {
|
||||
private constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final val x: R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
private final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
private final class Nested : R|kotlin/Any| {
|
||||
private constructor(): R|B.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final fun bar(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -4,15 +4,15 @@ FILE: simple.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final class MyNested : R|org/jetbrains/kotlin/fir/plugin/LibraryClassWithNestedClass.NestedClass| {
|
||||
public final class MyNested : <ERROR TYPE REF: Symbol not found for NestedClass> {
|
||||
public constructor(): R|A.MyNested| {
|
||||
super<R|ERROR CLASS: Symbol not found, for `NestedClass`|>()
|
||||
super<<ERROR TYPE REF: Symbol not found for NestedClass>>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/A.MyNested.MyNested|().R|org/jetbrains/kotlin/fir/plugin/LibraryClassWithNestedClass.NestedClass.foo|()
|
||||
R|/A.MyNested.MyNested|().<Unresolved name: foo>#()
|
||||
}
|
||||
|
||||
}
|
||||
+25
-33
@@ -6,120 +6,112 @@
|
||||
package org.jetbrains.kotlin.fir.plugin;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
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 org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("plugins/fir/fir-plugin-prototype/testData")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class FirAllOpenDiagnosticTestGenerated extends AbstractFirAllOpenDiagnosticTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInTestData() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("plugins/fir/fir-plugin-prototype/testData/checkers")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Checkers extends AbstractFirAllOpenDiagnosticTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public class Checkers {
|
||||
@Test
|
||||
public void testAllFilesPresentInCheckers() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData/checkers"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/checkers/simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("plugins/fir/fir-plugin-prototype/testData/memberGen")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class MemberGen extends AbstractFirAllOpenDiagnosticTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public class MemberGen {
|
||||
@Test
|
||||
public void testAllFilesPresentInMemberGen() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData/memberGen"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionForProperty.kt")
|
||||
public void testFunctionForProperty() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/memberGen/functionForProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/memberGen/nestedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("recursiveNestedClasses.kt")
|
||||
public void testRecursiveNestedClasses() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/memberGen/recursiveNestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelClass.kt")
|
||||
public void testTopLevelClass() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/memberGen/topLevelClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("plugins/fir/fir-plugin-prototype/testData/status")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Status extends AbstractFirAllOpenDiagnosticTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public class Status {
|
||||
@Test
|
||||
public void testAllFilesPresentInStatus() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData/status"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("metaAnnotation.kt")
|
||||
public void testMetaAnnotation() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/status/metaAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleAnnotation.kt")
|
||||
public void testSimpleAnnotation() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/status/simpleAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("visibilityTransformation.kt")
|
||||
public void testVisibilityTransformation() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/status/visibilityTransformation.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("plugins/fir/fir-plugin-prototype/testData/supertypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Supertypes extends AbstractFirAllOpenDiagnosticTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public class Supertypes {
|
||||
@Test
|
||||
public void testAllFilesPresentInSupertypes() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/fir/fir-plugin-prototype/testData/supertypes"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("plugins/fir/fir-plugin-prototype/testData/supertypes/simple.kt");
|
||||
+36
-13
@@ -7,24 +7,47 @@ package org.jetbrains.kotlin.fir.plugin
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.fir.AbstractFirDiagnosticsTest
|
||||
import org.jetbrains.kotlin.fir.extensions.BunchOfRegisteredExtensions
|
||||
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 : AbstractFirDiagnosticsTest() {
|
||||
override val pluginPhasesEnabled: Boolean
|
||||
get() = true
|
||||
abstract class AbstractFirAllOpenDiagnosticTest : AbstractKotlinCompilerTest() {
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
baseFirDiagnosticTestConfiguration(frontendFacade = facade)
|
||||
defaultDirectives {
|
||||
+ENABLE_PLUGIN_PHASES
|
||||
+FIR_DUMP
|
||||
}
|
||||
|
||||
override fun getFirExtensions(): BunchOfRegisteredExtensions {
|
||||
return FirAllOpenComponentRegistrar().configure()
|
||||
useConfigurators(::PluginAnnotationsProvider)
|
||||
}
|
||||
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
super.updateConfiguration(configuration)
|
||||
val jar = File("plugins/fir/fir-plugin-prototype/plugin-annotations/build/libs/plugin-annotations-1.5.255-SNAPSHOT.jar")
|
||||
if (!jar.exists()) {
|
||||
throw AssertionError("Jar with annotations does not exist. Please run :plugins:fir:fir-plugin-prototype:plugin-annotations:jar")
|
||||
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)
|
||||
}
|
||||
configuration.addJvmClasspathRoot(jar)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user