From fa20eb73f277bdd93302a46f4efe013329a44650 Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Fri, 20 Oct 2023 18:57:30 +0200 Subject: [PATCH] [Tests] Don't ignore expected file if diagnostic output is empty Because of this, `checkDiagnosticFullText.fir.diag.txt` was obsolete, because nothing was reported, but test was green. ^KT-62559 --- .../checkDiagnosticFullText.fir.diag.txt | 26 ------------------- .../fir/handlers/FirDiagnosticsHandler.kt | 9 +++++-- 2 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.diag.txt diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.diag.txt b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.diag.txt deleted file mode 100644 index 65032dfacd0..00000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.diag.txt +++ /dev/null @@ -1,26 +0,0 @@ -/jvm.kt:(106,113): warning: Annotation `@Ann()` is missing on actual declaration. -All annotations from expect 'class OnClass : Any' must be present with the same arguments on actual 'class OnClass : Any', otherwise they might behave incorrectly. - -/jvm.kt:(154,162): warning: Annotation `@Ann()` is missing on actual declaration. -All annotations from expect 'fun onMember(): Unit' must be present with the same arguments on actual 'fun onMember(): Unit', otherwise they might behave incorrectly. - -/jvm.kt:(212,224): warning: Annotation `@Ann()` is missing on actual declaration. -All annotations from expect 'class ViaTypealias : Any' must be present with the same arguments on actual 'class ViaTypealiasImpl : Any', otherwise they might behave incorrectly. - -/jvm.kt:(317,340): warning: Annotation `@Ann()` is missing on actual declaration. -All annotations from expect 'fun foo(): Unit' must be present with the same arguments on actual 'fun foo(): Unit', otherwise they might behave incorrectly. - -/jvm.kt:(405,421): warning: Annotation `@WithArg(s = String(str))` has different arguments on actual declaration: `@WithArg(s = String(other str))`. -All annotations from expect 'fun withDifferentArg(): Unit' must be present with the same arguments on actual 'fun withDifferentArg(): Unit', otherwise they might behave incorrectly. - -/jvm.kt:(439,451): warning: Annotation `@Ann()` is missing on actual declaration. -All annotations from expect 'fun inValueParam(arg: String): Unit' must be present with the same arguments on actual 'fun inValueParam(arg: String): Unit', otherwise they might behave incorrectly. - -/jvm.kt:(484,495): warning: Annotation `@Ann()` is missing on actual declaration. -All annotations from expect 'fun inTypeParam(): Unit' must be present with the same arguments on actual 'fun inTypeParam(): Unit', otherwise they might behave incorrectly. - -/jvm.kt:(513,521): warning: Annotation `@PROPERTY_GETTER:Ann()` is missing on actual declaration. -All annotations from expect 'val onGetter: String get(): String' must be present with the same arguments on actual 'val onGetter: String get(): String', otherwise they might behave incorrectly. - -/jvm.kt:(547,553): warning: Annotation `@Ann()` is missing on actual declaration. -All annotations from expect 'fun onType(param: @Ann() Any): Unit' must be present with the same arguments on actual 'fun onType(param: Any): Unit', otherwise they might behave incorrectly. diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt index 5a537659de7..bc05c584d9a 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt @@ -60,10 +60,15 @@ class FullDiagnosticsRenderer(private val directive: SimpleDirective) { private val dumper: MultiModuleInfoDumper = MultiModuleInfoDumper(moduleHeaderTemplate = "// -- Module: <%s> --") fun assertCollectedDiagnostics(testServices: TestServices, expectedExtension: String) { - if (dumper.isEmpty()) return - val resultDump = dumper.generateResultingDump() + if (directive !in testServices.moduleStructure.allDirectives) { + return + } val testDataFile = testServices.moduleStructure.originalTestDataFiles.first() val expectedFile = testDataFile.parentFile.resolve("${testDataFile.nameWithoutExtension.removeSuffix(".fir")}$expectedExtension") + if (dumper.isEmpty() && !expectedFile.exists()) { + return + } + val resultDump = dumper.generateResultingDump() testServices.assertions.assertEqualsToFile(expectedFile, resultDump) }