[FIR] Properly handle friend modules in modularized and full-pipeline tests
This commit is contained in:
+28
-23
@@ -28,20 +28,24 @@ data class ModuleData(
|
||||
val rawClasspath: List<String>,
|
||||
val rawSources: List<String>,
|
||||
val rawJavaSourceRoots: List<String>,
|
||||
val rawFriendDirs: List<String>,
|
||||
val isCommon: Boolean
|
||||
) {
|
||||
val qualifiedName get() = if (name in qualifier) qualifier else "$name.$qualifier"
|
||||
|
||||
val outputDir = File(ROOT_PATH_PREFIX, rawOutputDir.removePrefix("/"))
|
||||
val classpath = rawClasspath.map { File(ROOT_PATH_PREFIX, it.removePrefix("/")) }
|
||||
val sources = rawSources.map { File(ROOT_PATH_PREFIX, it.removePrefix("/")) }
|
||||
val javaSourceRoots = rawJavaSourceRoots.map { File(ROOT_PATH_PREFIX, it.removePrefix("/")) }
|
||||
val outputDir = rawOutputDir.fixPath()
|
||||
val classpath = rawClasspath.map { it.fixPath() }
|
||||
val sources = rawSources.map { it.fixPath() }
|
||||
val javaSourceRoots = rawJavaSourceRoots.map { it.fixPath() }
|
||||
val friendDirs = rawFriendDirs.map { it.fixPath() }
|
||||
lateinit var targetInfo: String
|
||||
var compilationError: String? = null
|
||||
var jvmInternalError: String? = null
|
||||
var exceptionMessage: String = "NO MESSAGE"
|
||||
}
|
||||
|
||||
private fun String.fixPath(): File = File(ROOT_PATH_PREFIX, this.removePrefix("/"))
|
||||
|
||||
private fun NodeList.toList(): List<Node> {
|
||||
val list = mutableListOf<Node>()
|
||||
for (index in 0 until this.length) {
|
||||
@@ -110,29 +114,30 @@ abstract class AbstractModularizedTest : KtUsefulTestCase() {
|
||||
val javaSourceRoots = mutableListOf<String>()
|
||||
val classpath = mutableListOf<String>()
|
||||
val sources = mutableListOf<String>()
|
||||
val friendDirs = mutableListOf<String>()
|
||||
var isCommon = false
|
||||
|
||||
for (index in 0 until moduleElement.childNodes.length) {
|
||||
val item = moduleElement.childNodes.item(index)
|
||||
|
||||
if (item.nodeName == "classpath") {
|
||||
val path = item.attributes.getNamedItem("path").nodeValue
|
||||
if (path != outputDir) {
|
||||
classpath += path
|
||||
when (item.nodeName) {
|
||||
"classpath" -> {
|
||||
val path = item.attributes.getNamedItem("path").nodeValue
|
||||
if (path != outputDir) {
|
||||
classpath += path
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.nodeName == "javaSourceRoots") {
|
||||
javaSourceRoots += item.attributes.getNamedItem("path").nodeValue
|
||||
}
|
||||
if (item.nodeName == "sources") {
|
||||
sources += item.attributes.getNamedItem("path").nodeValue
|
||||
}
|
||||
if (item.nodeName == "commonSources") {
|
||||
isCommon = true
|
||||
"friendDir" -> {
|
||||
val path = item.attributes.getNamedItem("path").nodeValue
|
||||
friendDirs += path
|
||||
}
|
||||
"javaSourceRoots" -> javaSourceRoots += item.attributes.getNamedItem("path").nodeValue
|
||||
"sources" -> sources += item.attributes.getNamedItem("path").nodeValue
|
||||
"commonSources" -> isCommon = true
|
||||
}
|
||||
}
|
||||
|
||||
return ModuleData(moduleName, outputDir, moduleNameQualifier, classpath, sources, javaSourceRoots, isCommon)
|
||||
return ModuleData(moduleName, outputDir, moduleNameQualifier, classpath, sources, javaSourceRoots, friendDirs, isCommon)
|
||||
}
|
||||
|
||||
|
||||
@@ -149,11 +154,11 @@ abstract class AbstractModularizedTest : KtUsefulTestCase() {
|
||||
println("BASE PATH: ${root.absolutePath}")
|
||||
|
||||
val filterRegex = (System.getProperty("fir.bench.filter") ?: ".*").toRegex()
|
||||
val modules =
|
||||
root.listFiles().filter { it.extension == "xml" }
|
||||
.sortedBy { it.lastModified() }.map { loadModule(it) }
|
||||
.filter { it.rawOutputDir.matches(filterRegex) }
|
||||
.filter { !it.isCommon }
|
||||
val files = root.listFiles() ?: emptyArray()
|
||||
val modules = files.filter { it.extension == "xml" }
|
||||
.sortedBy { it.lastModified() }.map { loadModule(it) }
|
||||
.filter { it.rawOutputDir.matches(filterRegex) }
|
||||
.filter { !it.isCommon }
|
||||
|
||||
|
||||
for (module in modules.progress(step = 0.0) { "Analyzing ${it.qualifiedName}" }) {
|
||||
|
||||
+7
-1
@@ -156,7 +156,13 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
|
||||
val scope = GlobalSearchScope.filesScope(project, ktFiles.map { it.virtualFile })
|
||||
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(project))
|
||||
val librariesScope = ProjectScope.getLibrariesScope(project)
|
||||
val session = createSessionForTests(environment, scope, librariesScope, moduleData.qualifiedName)
|
||||
val session = createSessionForTests(
|
||||
environment,
|
||||
scope,
|
||||
librariesScope,
|
||||
moduleData.qualifiedName,
|
||||
moduleData.friendDirs.map { it.canonicalPath }
|
||||
)
|
||||
val scopeSession = ScopeSession()
|
||||
val processors = createAllCompilerResolveProcessors(session, scopeSession).let {
|
||||
if (RUN_CHECKERS) {
|
||||
|
||||
+1
@@ -208,6 +208,7 @@ class FullPipelineModularizedTest : AbstractModularizedTest() {
|
||||
args.freeArgs = moduleData.sources.map { it.absolutePath }
|
||||
val tmp = Files.createTempDirectory("compile-output")
|
||||
args.destination = tmp.toAbsolutePath().toFile().toString()
|
||||
args.friendPaths = moduleData.friendDirs.map { it.canonicalPath }.toTypedArray()
|
||||
val manager = CompilerPerformanceManager()
|
||||
val services = Services.Builder().register(CommonCompilerPerformanceManager::class.java, manager).build()
|
||||
val collector = TestMessageCollector()
|
||||
|
||||
Reference in New Issue
Block a user