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