From 2c91ae112952b5f68a1c3a19e7fbbaeda0b81d45 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 1 Aug 2023 14:57:39 +0300 Subject: [PATCH] [Test] Report backend diagnostics from dependant MPP modules for FIR codegen tests --- .../handlers/JvmBackendDiagnosticsHandler.kt | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBackendDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBackendDiagnosticsHandler.kt index 52774fc7871..f8975ffeac1 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBackendDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBackendDiagnosticsHandler.kt @@ -24,11 +24,9 @@ import org.jetbrains.kotlin.test.frontend.classic.handlers.withNewInferenceModeE import org.jetbrains.kotlin.test.frontend.fir.handlers.FirDiagnosticCodeMetaInfo import org.jetbrains.kotlin.test.frontend.fir.handlers.toMetaInfos import org.jetbrains.kotlin.test.model.BinaryArtifacts +import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.TestModule -import org.jetbrains.kotlin.test.services.TestServices -import org.jetbrains.kotlin.test.services.assertions -import org.jetbrains.kotlin.test.services.globalMetadataInfoHandler -import org.jetbrains.kotlin.test.services.sourceFileProvider +import org.jetbrains.kotlin.test.services.* import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly import org.junit.jupiter.api.fail import java.io.File @@ -63,13 +61,25 @@ class JvmBackendDiagnosticsHandler(testServices: TestServices) : JvmBinaryArtifa val firParser = module.directives.singleOrZeroValue(FirDiagnosticsDirectives.FIR_PARSER) val lightTreeComparingModeEnabled = firParser != null && FirDiagnosticsDirectives.COMPARE_WITH_LIGHT_TREE in module.directives val lightTreeEnabled = firParser == FirParser.LightTree - for (testFile in module.files) { - val ktDiagnostics = ktDiagnosticReporter.diagnosticsByFilePath["/${testFile.name}"] ?: continue - ktDiagnostics.forEach { - val metaInfos = it.toMetaInfos(module, testFile, globalMetadataInfoHandler, lightTreeEnabled, lightTreeComparingModeEnabled) - globalMetadataInfoHandler.addMetadataInfosForFile(testFile, metaInfos) + + val processedModules = mutableSetOf() + + fun processModule(module: TestModule) { + if (!processedModules.add(module)) return + for (testFile in module.files) { + val ktDiagnostics = ktDiagnosticReporter.diagnosticsByFilePath["/${testFile.name}"] ?: continue + ktDiagnostics.forEach { + val metaInfos = it.toMetaInfos(module, testFile, globalMetadataInfoHandler, lightTreeEnabled, lightTreeComparingModeEnabled) + globalMetadataInfoHandler.addMetadataInfosForFile(testFile, metaInfos) + } + } + for ((moduleName, _, _) in module.dependsOnDependencies) { + val dependantModule = testServices.dependencyProvider.getTestModule(moduleName) + processModule(dependantModule) } } + + processModule(module) } private fun checkFullDiagnosticRender(module: TestModule) {