AA: introduce static project structure provider by compiler configuration
Also add standalone mode utils to configure Application/Project environments
This commit is contained in:
committed by
Ilya Kirillov
parent
d219de0f88
commit
26e923e3ae
@@ -14,9 +14,10 @@ dependencies {
|
||||
testApi(projectTests(":generators:test-generator"))
|
||||
testApi(projectTests(":compiler:tests-common"))
|
||||
testApi(projectTests(":compiler:tests-spec"))
|
||||
testApi(projectTests("::analysis:low-level-api-fir"))
|
||||
testApi(projectTests(":analysis:low-level-api-fir"))
|
||||
testApi(projectTests(":analysis:analysis-api-fir"))
|
||||
testApi(projectTests(":analysis:analysis-api-fe10"))
|
||||
testApi(projectTests(":analysis:analysis-api-standalone"))
|
||||
testApi(projectTests(":analysis:decompiled:decompiler-to-file-stubs"))
|
||||
testApi(projectTests(":analysis:symbol-light-classes"))
|
||||
testApi(intellijCore())
|
||||
@@ -25,4 +26,4 @@ dependencies {
|
||||
|
||||
val generateFrontendApiTests by generator("org.jetbrains.kotlin.generators.tests.analysis.api.GenerateAnalysisApiTestsKt")
|
||||
|
||||
testsJar()
|
||||
testsJar()
|
||||
|
||||
+1
@@ -21,4 +21,5 @@ private fun TestGroupSuite.generateTests() {
|
||||
generateFirLowLevelApiTests()
|
||||
generateDecompiledTests()
|
||||
generateSymbolLightClassesTests()
|
||||
generateStandaloneModeTests()
|
||||
}
|
||||
|
||||
-1
@@ -42,7 +42,6 @@ import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.component
|
||||
import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.group
|
||||
import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.test
|
||||
import org.jetbrains.kotlin.generators.util.TestGeneratorUtil
|
||||
import java.nio.file.Paths
|
||||
|
||||
fun TestGroupSuite.generateAnalysisApiTests() {
|
||||
generateAnalysisApiComponentsTests()
|
||||
|
||||
+10
-7
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.analysis.api.fir.FirFrontendApiTestConfiguratorServi
|
||||
import org.jetbrains.kotlin.analysis.api.fir.utils.libraries.binary.LibraryFrontendApiTestConfiguratorService
|
||||
import org.jetbrains.kotlin.analysis.api.fir.utils.libraries.source.LibrarySourceFrontendApiTestConfiguratorService
|
||||
import org.jetbrains.kotlin.analysis.api.impl.barebone.test.FrontendApiTestConfiguratorService
|
||||
import org.jetbrains.kotlin.analysis.api.standalone.StandaloneModeConfiguratorService
|
||||
import org.jetbrains.kotlin.generators.TestGroup
|
||||
import org.jetbrains.kotlin.generators.TestGroupSuite
|
||||
import org.jetbrains.kotlin.generators.getDefaultSuiteTestClassName
|
||||
@@ -27,6 +28,8 @@ internal sealed class TestModuleKind(val componentName: String) {
|
||||
object LIBRARY : TestModuleKind("library")
|
||||
object LIBRARY_SOURCE : TestModuleKind("librarySource")
|
||||
|
||||
object STANDALONE_MODE : TestModuleKind("StandaloneMode")
|
||||
|
||||
companion object {
|
||||
val SOURCE_ONLY by lazy(LazyThreadSafetyMode.NONE) { listOf(SOURCE) }
|
||||
val SOURCE_AND_LIBRARY_SOURCE by lazy(LazyThreadSafetyMode.NONE) { listOf(SOURCE, LIBRARY_SOURCE) }
|
||||
@@ -59,7 +62,6 @@ internal fun FirAndFe10TestGroup.test(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal fun TestGroupSuite.test(
|
||||
baseClass: KClass<*>,
|
||||
addFe10: Boolean = true,
|
||||
@@ -69,20 +71,19 @@ internal fun TestGroupSuite.test(
|
||||
FirAndFe10TestGroup(this, directory = null, testModuleKinds).test(baseClass, addFe10, init)
|
||||
}
|
||||
|
||||
|
||||
internal fun TestGroupSuite.group(
|
||||
directory: String,
|
||||
testModuleKinds: List<TestModuleKind> = TestModuleKind.SOURCE_ONLY,
|
||||
init: FirAndFe10TestGroup.() -> Unit,
|
||||
) {
|
||||
FirAndFe10TestGroup(this, directory, testModuleKinds = listOf(TestModuleKind.SOURCE)).init()
|
||||
FirAndFe10TestGroup(this, directory, testModuleKinds).init()
|
||||
}
|
||||
|
||||
|
||||
internal fun TestGroupSuite.component(
|
||||
directory: String,
|
||||
init: FirAndFe10TestGroup.() -> Unit,
|
||||
) {
|
||||
group("components/$directory", init)
|
||||
group("components/$directory", init = init)
|
||||
}
|
||||
|
||||
private fun FirAndFe10TestGroup.analysisApiTest(
|
||||
@@ -95,7 +96,7 @@ private fun FirAndFe10TestGroup.analysisApiTest(
|
||||
val fullTestPath = "analysis/analysis-api/testData" + directory?.let { "/$it" }.orEmpty()
|
||||
testGroup(testRoot, fullTestPath) {
|
||||
if (testModuleKinds.size == 1) {
|
||||
analysisApiTestClass(frontend, moduleKind = TestModuleKind.SOURCE, testClass, prefixNeeded = false, init)
|
||||
analysisApiTestClass(frontend, moduleKind = testModuleKinds.single(), testClass, prefixNeeded = false, init)
|
||||
} else {
|
||||
testModuleKinds.forEach { component ->
|
||||
analysisApiTestClass(frontend, component, testClass, prefixNeeded = true, init)
|
||||
@@ -138,7 +139,7 @@ private fun TestGroup.analysisApiTestClass(
|
||||
}
|
||||
}
|
||||
|
||||
private fun createConfigurator(
|
||||
internal fun createConfigurator(
|
||||
frontend: Frontend,
|
||||
moduleKind: TestModuleKind
|
||||
): KClass<out FrontendApiTestConfiguratorService> = when (frontend) {
|
||||
@@ -146,11 +147,13 @@ private fun createConfigurator(
|
||||
TestModuleKind.SOURCE -> FirFrontendApiTestConfiguratorService::class
|
||||
TestModuleKind.LIBRARY -> LibraryFrontendApiTestConfiguratorService::class
|
||||
TestModuleKind.LIBRARY_SOURCE -> LibrarySourceFrontendApiTestConfiguratorService::class
|
||||
TestModuleKind.STANDALONE_MODE -> StandaloneModeConfiguratorService::class
|
||||
}
|
||||
Frontend.FE10 -> when (moduleKind) {
|
||||
TestModuleKind.SOURCE -> KtFe10FrontendApiTestConfiguratorService::class
|
||||
TestModuleKind.LIBRARY -> TODO("TestModuleKind.LIBRARY is unsupported for fe10")
|
||||
TestModuleKind.LIBRARY_SOURCE -> TODO("TestModuleKind.LIBRARY_SOURCE is unsupported for fe10")
|
||||
TestModuleKind.STANDALONE_MODE -> TODO("TestModuleKind.STANDALONE_MODE is unsupported for fe10")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.generators.tests.analysis.api
|
||||
|
||||
import org.jetbrains.kotlin.generators.TestGroupSuite
|
||||
import org.jetbrains.kotlin.analysis.api.standalone.AbstractStandaloneModeSingleModuleTest
|
||||
import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.Frontend
|
||||
import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.FrontendConfiguratorTestModel
|
||||
import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.TestModuleKind
|
||||
import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.createConfigurator
|
||||
|
||||
internal fun TestGroupSuite.generateStandaloneModeTests() {
|
||||
testGroup(
|
||||
"analysis/analysis-api-standalone/tests",
|
||||
"analysis/analysis-api/testData"
|
||||
) {
|
||||
val configurator = createConfigurator(Frontend.FIR, TestModuleKind.STANDALONE_MODE)
|
||||
testClass<AbstractStandaloneModeSingleModuleTest> {
|
||||
method(FrontendConfiguratorTestModel(configurator))
|
||||
model("standalone/singleModule")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user