Analysis API FIR: introduce library resolve tests

This commit is contained in:
Ilya Kirillov
2022-01-25 16:46:43 +01:00
parent 96e1f1e7d4
commit caddbda01b
22 changed files with 1784 additions and 128 deletions
@@ -158,7 +158,12 @@ abstract class AbstractFrontendApiTest : TestWithDisposable() {
testConfiguration.directives,
)
val singleModule = moduleStructure.modules.single()
val project = testServices.compilerConfigurationProvider.getProject(singleModule)
val project = try {
testServices.compilerConfigurationProvider.getProject(singleModule)
} catch (_: SkipTestException) {
return
}
val moduleInfoProvider = testServices.projectModuleProvider
with(project as MockProject) {
configurator.registerProjectServices(this)
@@ -183,6 +188,7 @@ abstract class AbstractFrontendApiTest : TestWithDisposable() {
val ktFiles = when (moduleInfo) {
is TestKtSourceModule -> moduleInfo.testFilesToKtFiles.filterKeys { testFile -> !testFile.isAdditional }.values.toList()
is TestKtLibraryModule -> moduleInfo.ktFiles.toList()
is TestKtLibrarySourceModule -> moduleInfo.ktFiles.toList()
else -> error("Unexpected $moduleInfo")
}
@@ -0,0 +1,8 @@
/*
* 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.analysis.api.impl.barebone.test
abstract class SkipTestException : RuntimeException()
@@ -119,6 +119,19 @@ class TestKtLibraryModule(
GlobalSearchScope.filesScope(project, ktFiles.map { it.virtualFile })
}
class TestKtLibrarySourceModule(
project: Project,
testModule: TestModule,
ktFilesFromSourceJar: Set<KtFile>,
testServices: TestServices,
override val binaryLibrary: KtLibraryModule,
) : TestKtModule(project, testModule, ktFilesFromSourceJar, testServices), KtLibrarySourceModule {
override val ktModule: KtModule get() = this
override val contentScope: GlobalSearchScope get() = GlobalSearchScope.filesScope(project, ktFiles.map { it.virtualFile })
override val libraryName: String get() = testModule.name
}
private class LibraryByRoots(
private val roots: List<Path>,
private val module: KtModule,