From ca02573d1eb1044be28b960499699f7ea188543d Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 4 Feb 2021 10:46:03 +0300 Subject: [PATCH] [Test] Print bytecode if DxCheckerHandler had failed --- .../test/backend/handlers/DxCheckerHandler.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt index 0508bdf41e6..5d702a732e4 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt @@ -20,7 +20,22 @@ class DxCheckerHandler(testServices: TestServices) : JvmBinaryArtifactHandler(te override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) { if (RUN_DEX_CHECKER !in module.directives || IGNORE_DEXING in module.directives) return - D8Checker.check(info.classFileFactory) + val reportProblems = module.targetBackend !in module.directives[CodegenTestDirectives.IGNORE_BACKEND] + try { + D8Checker.check(info.classFileFactory) + } catch (e: Throwable) { + if (reportProblems) { + try { + println(info.classFileFactory.createText()) + } catch (_: Throwable) { + // In FIR we have factory which can't print bytecode + // and it throws exception otherwise. So we need + // ignore that exception to report original one + // TODO: fix original problem + } + } + throw e + } } override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}