From 12caf5d743501ba8e179f6810eb9656a6b1fbfb3 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 13 Jan 2021 18:18:14 +0300 Subject: [PATCH] Fix test BE JvmBoxRunner to be able to see FIR BB tests exceptions --- .../kotlin/test/backend/handlers/JvmBoxRunner.kt | 9 ++++++++- .../org/jetbrains/kotlin/codegen/CodegenTestUtil.java | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt index 714a5978738..9cbf73360da 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt @@ -76,7 +76,14 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe callBoxMethodAndCheckResult(classLoader, clazz, method, unexpectedBehaviour) } catch (e: Throwable) { if (reportProblems) { - println(factory.createText()) + try { + println(factory.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 } finally { diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/CodegenTestUtil.java b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/CodegenTestUtil.java index a83a33699df..d5a39012f2f 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/CodegenTestUtil.java +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/CodegenTestUtil.java @@ -218,8 +218,15 @@ public class CodegenTestUtil { } catch (Throwable e) { if (reportProblems) { - System.err.println(file.asText()); - System.err.println(classNode.name + "::" + method.name + method.desc); + try { + System.err.println(file.asText()); + System.err.println(classNode.name + "::" + method.name + method.desc); + } catch (Throwable ex) { + // 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 + } //noinspection InstanceofCatchParameter if (e instanceof AnalyzerException) {