Analysis API: move reference resolve testsdata with errors to dedicated folders
This commit is contained in:
+11
-4
@@ -37,12 +37,12 @@ import org.jetbrains.kotlin.analysis.api.impl.base.test.symbols.AbstractSymbolBy
|
||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.symbols.AbstractSymbolByPsiTest
|
||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.symbols.AbstractSymbolByReferenceTest
|
||||
import org.jetbrains.kotlin.generators.TestGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.*
|
||||
import org.jetbrains.kotlin.generators.tests.analysis.api.dsl.TestModuleKind
|
||||
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()
|
||||
@@ -52,10 +52,17 @@ fun TestGroupSuite.generateAnalysisApiTests() {
|
||||
private fun TestGroupSuite.generateAnalysisApiNonComponentsTests() {
|
||||
test(
|
||||
AbstractReferenceResolveTest::class,
|
||||
testModuleKinds = TestModuleKind.SOURCES_AND_LIBRARIES_SOURCES,
|
||||
testModuleKinds = TestModuleKind.SOURCE_AND_LIBRARY_SOURCE,
|
||||
addFe10 = false,
|
||||
) {
|
||||
model("referenceResolve", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME)
|
||||
) { moduleKind ->
|
||||
when (moduleKind) {
|
||||
TestModuleKind.LIBRARY_SOURCE -> {
|
||||
model("referenceResolve", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME, excludeDirsRecursively = listOf("withErrors"))
|
||||
}
|
||||
else -> {
|
||||
model("referenceResolve", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group("scopes") {
|
||||
|
||||
+19
-16
@@ -28,8 +28,8 @@ internal sealed class TestModuleKind(val componentName: String) {
|
||||
object LIBRARY_SOURCE : TestModuleKind("librarySource")
|
||||
|
||||
companion object {
|
||||
val SOURCES_ONLY = listOf(SOURCE)
|
||||
val SOURCES_AND_LIBRARIES_SOURCES = listOf(SOURCE, LIBRARY_SOURCE)
|
||||
val SOURCE_ONLY by lazy(LazyThreadSafetyMode.NONE) { listOf(SOURCE) }
|
||||
val SOURCE_AND_LIBRARY_SOURCE by lazy(LazyThreadSafetyMode.NONE) { listOf(SOURCE, LIBRARY_SOURCE) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ internal enum class Frontend(val prefix: String) {
|
||||
internal fun FirAndFe10TestGroup.test(
|
||||
baseClass: KClass<*>,
|
||||
generateFe10: Boolean = true,
|
||||
init: TestGroup.TestClass.() -> Unit,
|
||||
init: TestGroup.TestClass.(module: TestModuleKind) -> Unit,
|
||||
) {
|
||||
analysisApiTest(
|
||||
"analysis/analysis-api-fir/tests",
|
||||
@@ -63,8 +63,8 @@ internal fun FirAndFe10TestGroup.test(
|
||||
internal fun TestGroupSuite.test(
|
||||
baseClass: KClass<*>,
|
||||
addFe10: Boolean = true,
|
||||
testModuleKinds: List<TestModuleKind> = TestModuleKind.SOURCES_ONLY,
|
||||
init: TestGroup.TestClass.() -> Unit,
|
||||
testModuleKinds: List<TestModuleKind> = TestModuleKind.SOURCE_ONLY,
|
||||
init: TestGroup.TestClass.(module: TestModuleKind) -> Unit,
|
||||
) {
|
||||
FirAndFe10TestGroup(this, directory = null, testModuleKinds).test(baseClass, addFe10, init)
|
||||
}
|
||||
@@ -72,26 +72,24 @@ internal fun TestGroupSuite.test(
|
||||
|
||||
internal fun TestGroupSuite.group(
|
||||
directory: String,
|
||||
testModuleKinds: List<TestModuleKind> = TestModuleKind.SOURCES_ONLY,
|
||||
init: FirAndFe10TestGroup.() -> Unit,
|
||||
) {
|
||||
FirAndFe10TestGroup(this, directory, testModuleKinds).init()
|
||||
FirAndFe10TestGroup(this, directory, testModuleKinds = listOf(TestModuleKind.SOURCE)).init()
|
||||
}
|
||||
|
||||
|
||||
internal fun TestGroupSuite.component(
|
||||
directory: String,
|
||||
moduleKinds: List<TestModuleKind> = TestModuleKind.SOURCES_ONLY,
|
||||
init: FirAndFe10TestGroup.() -> Unit,
|
||||
) {
|
||||
group("components/$directory", moduleKinds, init)
|
||||
group("components/$directory", init)
|
||||
}
|
||||
|
||||
private fun FirAndFe10TestGroup.analysisApiTest(
|
||||
testRoot: String,
|
||||
frontend: Frontend,
|
||||
testClass: KClass<*>,
|
||||
init: TestGroup.TestClass.() -> Unit,
|
||||
init: TestGroup.TestClass.(module: TestModuleKind) -> Unit,
|
||||
) {
|
||||
with(suite) {
|
||||
val fullTestPath = "analysis/analysis-api/testData" + directory?.let { "/$it" }.orEmpty()
|
||||
@@ -112,14 +110,19 @@ private fun TestGroup.analysisApiTestClass(
|
||||
moduleKind: TestModuleKind,
|
||||
testClass: KClass<*>,
|
||||
prefixNeeded: Boolean,
|
||||
init: TestGroup.TestClass.() -> Unit
|
||||
init: TestGroup.TestClass.(module: TestModuleKind) -> Unit
|
||||
) {
|
||||
val fullPackage = getPackageName(frontend.prefix, testClass)
|
||||
|
||||
val suiteTestClassName = fullPackage +
|
||||
frontend.prefix +
|
||||
moduleKind.componentName.capitalizeAsciiOnly().takeIf { prefixNeeded }.orEmpty() +
|
||||
getDefaultSuiteTestClassName(testClass.java.simpleName)
|
||||
val suiteTestClassName = buildString {
|
||||
append(fullPackage)
|
||||
append(frontend.prefix)
|
||||
moduleKind.componentName
|
||||
.capitalizeAsciiOnly()
|
||||
.takeIf { prefixNeeded }
|
||||
?.let(::append)
|
||||
append(getDefaultSuiteTestClassName(testClass.java.simpleName))
|
||||
}
|
||||
|
||||
getDefaultSuiteTestClassName(testClass.java.simpleName)
|
||||
|
||||
@@ -131,7 +134,7 @@ private fun TestGroup.analysisApiTestClass(
|
||||
useJunit4 = false
|
||||
) {
|
||||
method(FrontendConfiguratorTestModel(configurator))
|
||||
init()
|
||||
init(moduleKind)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -82,6 +82,8 @@ class TestGroup(
|
||||
val annotations: List<AnnotationModel>,
|
||||
val targetBackendComputer: TargetBackendComputer
|
||||
) {
|
||||
val testDataRoot: String
|
||||
get() = this@TestGroup.testDataRoot
|
||||
val baseDir: String
|
||||
get() = this@TestGroup.testsRoot
|
||||
|
||||
@@ -106,6 +108,7 @@ class TestGroup(
|
||||
// directives TARGET_BACKEND/DONT_TARGET_EXACT_BACKEND won't be generated
|
||||
targetBackend: TargetBackend? = null,
|
||||
excludeDirs: List<String> = listOf(),
|
||||
excludeDirsRecursively: List<String> = listOf(),
|
||||
filenameStartsLowerCase: Boolean? = null, // assert that file is properly named
|
||||
skipIgnored: Boolean = false, // pretty meaningless flag, affects only few test names in one test runner
|
||||
deep: Int? = null, // specifies how deep recursive search will follow directory with testdata
|
||||
@@ -128,7 +131,7 @@ class TestGroup(
|
||||
SimpleTestClassModel(
|
||||
rootFile, recursive, excludeParentDirs,
|
||||
compiledPattern, compiledExcludedPattern, filenameStartsLowerCase, testMethod, className,
|
||||
realTargetBackend, excludeDirs, skipIgnored, testRunnerMethodName, additionalRunnerArguments, deep, annotations,
|
||||
realTargetBackend, excludeDirs, excludeDirsRecursively, skipIgnored, testRunnerMethodName, additionalRunnerArguments, deep, annotations,
|
||||
extractTagsFromDirectory(rootFile), methodModels
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ object SimpleTestClassModelTestAllFilesPresentMethodGenerator : MethodGenerator<
|
||||
override fun generateBody(method: SimpleTestClassModel.TestAllFilesPresentMethodModel, p: Printer) {
|
||||
with(method) {
|
||||
val exclude = StringBuilder()
|
||||
for (dir in classModel.excludeDirs) {
|
||||
for (dir in classModel.excludeDirs + classModel.excludeDirsRecursively) {
|
||||
exclude.append(", \"")
|
||||
exclude.append(StringUtil.escapeStringCharacters(dir))
|
||||
exclude.append("\"")
|
||||
|
||||
+4
-1
@@ -25,6 +25,7 @@ class SimpleTestClassModel(
|
||||
private val testClassName: String,
|
||||
val targetBackend: TargetBackend,
|
||||
excludeDirs: Collection<String>,
|
||||
excludeDirsRecursively: Collection<String>,
|
||||
private val skipIgnored: Boolean,
|
||||
private val testRunnerMethodName: String,
|
||||
private val additionalRunnerArguments: List<String>,
|
||||
@@ -37,6 +38,7 @@ class SimpleTestClassModel(
|
||||
get() = testClassName
|
||||
|
||||
val excludeDirs: Set<String> = excludeDirs.toSet()
|
||||
val excludeDirsRecursively: Set<String> = excludeDirsRecursively.toSet()
|
||||
|
||||
override val innerTestClasses: Collection<TestClassModel> by lazy {
|
||||
if (!rootFile.isDirectory || !recursive || deep != null && deep < 1) {
|
||||
@@ -45,7 +47,7 @@ class SimpleTestClassModel(
|
||||
val children = mutableListOf<TestClassModel>()
|
||||
val files = rootFile.listFiles() ?: return@lazy emptyList()
|
||||
for (file in files) {
|
||||
if (file.isDirectory && dirHasFilesInside(file) && !excludeDirs.contains(file.name)) {
|
||||
if (file.isDirectory && dirHasFilesInside(file) && !excludeDirs.contains(file.name) && !excludeDirsRecursively.contains(file.name)) {
|
||||
val innerTestClassName = fileNameToJavaIdentifier(file)
|
||||
children.add(
|
||||
SimpleTestClassModel(
|
||||
@@ -59,6 +61,7 @@ class SimpleTestClassModel(
|
||||
innerTestClassName,
|
||||
targetBackend,
|
||||
excludesStripOneDirectory(file.name),
|
||||
excludeDirsRecursively,
|
||||
skipIgnored,
|
||||
testRunnerMethodName,
|
||||
additionalRunnerArguments,
|
||||
|
||||
Reference in New Issue
Block a user