From 9935519656a7af198d55f5d8859ab6bcd53410f4 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 26 Jun 2023 15:03:09 +0200 Subject: [PATCH] Tests: add RENDER_ALL_DIAGNOSTICS_FULL_TEXT directive Use it in diagnostic tests with JVM backend instead of the RENDER_DIAGNOSTICS_FULL_TEXT directive. This is needed because otherwise in AbstractDiagnosticsTestWithJvmBackend there are two handlers trying to dump full diagnostic texts: JvmBackendDiagnosticsHandler and FirDiagnosticsHandler, which dump different diagnostics (reported by backend vs frontend) and in slightly different formats. In fact, this is why exceptionFromInterpreter.fir.diag.txt was added in 48484368c7: the existing .diag.txt was detected as incorrect by FirDiagnosticsHandler (even though the diagnostics are the same, just printed in a different way), which led to the creation of .fir.diag.txt. For these tests, the behavior about checking diagnostic text in FirDiagnosticsHandler is useless because it doesn't include backend diagnostics. So we disable it by using another directive. --- .../exceptionFromInterpreter.fir.diag.txt | 5 ----- .../firTestWithJvmBackend/exceptionFromInterpreter.kt | 2 +- .../diagnostics/testsWithJvmBackend/indirectInlineCycle.kt | 4 ++-- .../testData/diagnostics/testsWithJvmBackend/inlineCycle.kt | 4 ++-- .../testsWithJvmBackend/scripts/enumCapturesProperty.kts | 2 +- .../scripts/enumEntryCapturesProperty.kts | 2 +- .../scripts/interfaceCapturesProperty.kts | 2 +- .../scripts/nestedAndOuterClassesCaptureProperty.kts | 2 +- .../scripts/nestedClassCapturesProperty.kts | 2 +- .../scripts/nestedToObjectClassCapturesProperty.kts | 2 +- .../testsWithJvmBackend/scripts/objectCapturesProperty.kts | 2 +- .../scripts/objectCapturesPropertyIndirect.kts | 2 +- .../scripts/objectCapturesPropertyViaExtension1.kts | 2 +- .../scripts/objectCapturesPropertyViaExtension2.kts | 2 +- .../diagnostics/testsWithJvmBackend/suspendInlineCycle.kt | 4 ++-- .../test/backend/handlers/JvmBackendDiagnosticsHandler.kt | 2 +- .../kotlin/test/directives/DiagnosticsDirectives.kt | 6 +++++- 17 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 compiler/testData/diagnostics/firTestWithJvmBackend/exceptionFromInterpreter.fir.diag.txt diff --git a/compiler/testData/diagnostics/firTestWithJvmBackend/exceptionFromInterpreter.fir.diag.txt b/compiler/testData/diagnostics/firTestWithJvmBackend/exceptionFromInterpreter.fir.diag.txt deleted file mode 100644 index 91cb8a9ba42..00000000000 --- a/compiler/testData/diagnostics/firTestWithJvmBackend/exceptionFromInterpreter.fir.diag.txt +++ /dev/null @@ -1,5 +0,0 @@ -/exceptionFromInterpreter.kt:(174,179): warning: Division by zero - -/exceptionFromInterpreter.kt:(205,210): warning: Division by zero - -/exceptionFromInterpreter.kt:(243,264): error: Const 'val' initializer should be a constant value diff --git a/compiler/testData/diagnostics/firTestWithJvmBackend/exceptionFromInterpreter.kt b/compiler/testData/diagnostics/firTestWithJvmBackend/exceptionFromInterpreter.kt index 3c2e1027cff..cea6947287b 100644 --- a/compiler/testData/diagnostics/firTestWithJvmBackend/exceptionFromInterpreter.kt +++ b/compiler/testData/diagnostics/firTestWithJvmBackend/exceptionFromInterpreter.kt @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT // TARGET_BACKEND: JVM_IR // !DIAGNOSTICS: -CONST_VAL_WITH_NON_CONST_INITIALIZER, -DIVISION_BY_ZERO // WITH_STDLIB diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/indirectInlineCycle.kt b/compiler/testData/diagnostics/testsWithJvmBackend/indirectInlineCycle.kt index d6188edd8b1..ed38f360b82 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/indirectInlineCycle.kt +++ b/compiler/testData/diagnostics/testsWithJvmBackend/indirectInlineCycle.kt @@ -1,5 +1,5 @@ // FIR_IDENTICAL -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT inline fun inlineFun1(crossinline p: () -> Unit) { object { @@ -9,4 +9,4 @@ inline fun inlineFun1(crossinline p: () -> Unit) { inline fun inlineFun2(crossinline p: () -> Unit) { inlineFun1(p) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/inlineCycle.kt b/compiler/testData/diagnostics/testsWithJvmBackend/inlineCycle.kt index 024ae594780..58b1b2a376a 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/inlineCycle.kt +++ b/compiler/testData/diagnostics/testsWithJvmBackend/inlineCycle.kt @@ -1,5 +1,5 @@ // FIR_IDENTICAL -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT inline fun inlineFun1(p: () -> Unit) { p() @@ -9,4 +9,4 @@ inline fun inlineFun1(p: () -> Unit) { inline fun inlineFun2(p: () -> Unit) { p() inlineFun1(p) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/enumCapturesProperty.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/enumCapturesProperty.kts index 9b02964e5c9..0acf837c889 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/enumCapturesProperty.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/enumCapturesProperty.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT // KT-30616 diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/enumEntryCapturesProperty.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/enumEntryCapturesProperty.kts index b3adab02a90..7b0fc354dee 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/enumEntryCapturesProperty.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/enumEntryCapturesProperty.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT // KT-30616 diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/interfaceCapturesProperty.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/interfaceCapturesProperty.kts index d7097272c71..d4f8d5c181b 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/interfaceCapturesProperty.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/interfaceCapturesProperty.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT fun foo() = B().bar() diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedAndOuterClassesCaptureProperty.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedAndOuterClassesCaptureProperty.kts index 2730f1c7715..36ebe0b982e 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedAndOuterClassesCaptureProperty.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedAndOuterClassesCaptureProperty.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT // KT-19423 variation diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedClassCapturesProperty.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedClassCapturesProperty.kts index 202a446f379..3c7afe8647b 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedClassCapturesProperty.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedClassCapturesProperty.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT // KT-19423 variation diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedToObjectClassCapturesProperty.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedToObjectClassCapturesProperty.kts index c2c364be42e..ccce26baf0f 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedToObjectClassCapturesProperty.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/nestedToObjectClassCapturesProperty.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT // KT-19423 variation diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesProperty.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesProperty.kts index d46fb9e6bb3..3d289b9ebd0 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesProperty.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesProperty.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT fun foo() = B.bar() diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyIndirect.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyIndirect.kts index 54514392d27..81a1277c790 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyIndirect.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyIndirect.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT fun foo() = B.bar() diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyViaExtension1.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyViaExtension1.kts index 9ffabcc0eae..312437eda38 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyViaExtension1.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyViaExtension1.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT // see KT-49443 diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyViaExtension2.kts b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyViaExtension2.kts index bd5b716fcfe..3ab7a569e6f 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyViaExtension2.kts +++ b/compiler/testData/diagnostics/testsWithJvmBackend/scripts/objectCapturesPropertyViaExtension2.kts @@ -1,4 +1,4 @@ -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT // see KT-49443 diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/suspendInlineCycle.kt b/compiler/testData/diagnostics/testsWithJvmBackend/suspendInlineCycle.kt index 424441f0d33..55ac61b7b40 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/suspendInlineCycle.kt +++ b/compiler/testData/diagnostics/testsWithJvmBackend/suspendInlineCycle.kt @@ -1,5 +1,5 @@ // FIR_IDENTICAL -// !RENDER_DIAGNOSTICS_FULL_TEXT +// !RENDER_ALL_DIAGNOSTICS_FULL_TEXT suspend inline fun inlineFun1(p: () -> Unit) { p() @@ -9,4 +9,4 @@ suspend inline fun inlineFun1(p: () -> Unit) { suspend inline fun inlineFun2(p: () -> Unit) { p() inlineFun1(p) -} \ No newline at end of file +} 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 76bdc4d1c5d..67923037a7f 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 @@ -84,7 +84,7 @@ class JvmBackendDiagnosticsHandler(testServices: TestServices) : JvmBinaryArtifa } private fun checkFullDiagnosticRender(module: TestModule) { - if (DiagnosticsDirectives.RENDER_DIAGNOSTICS_FULL_TEXT !in module.directives) return + if (DiagnosticsDirectives.RENDER_ALL_DIAGNOSTICS_FULL_TEXT !in module.directives) return val testFileToKtFileMap = getKtFiles(module) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/DiagnosticsDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/DiagnosticsDirectives.kt index 4bade6fbc02..24ad8412358 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/DiagnosticsDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/DiagnosticsDirectives.kt @@ -86,6 +86,10 @@ object DiagnosticsDirectives : SimpleDirectivesContainer() { ) val RENDER_DIAGNOSTICS_FULL_TEXT by directive( - description = "Render diagnostic texts to .diag.txt" + description = "Render frontend diagnostic texts to .diag.txt" + ) + + val RENDER_ALL_DIAGNOSTICS_FULL_TEXT by directive( + description = "Render both frontend and backend diagnostic texts to .diag.txt" ) }