From c22272bbcaffb88ad0868428da3fb24752724a55 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 25 Feb 2020 16:35:20 +0300 Subject: [PATCH] Enable mute for KotlinCompletionTestCase --- .../org/jetbrains/kotlin/test/KotlinTestUtils.java | 12 ++++++++++++ .../jetbrains/kotlin/test/RunnableWithThrowable.java | 10 ++++++++++ .../completion/test/KotlinCompletionTestCase.java | 6 ++++++ 3 files changed, 28 insertions(+) create mode 100644 compiler/tests-common/tests/org/jetbrains/kotlin/test/RunnableWithThrowable.java diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index 487b0183172..f8a0769cb45 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -717,6 +717,18 @@ public class KotlinTestUtils { MuteWithDatabaseKt.runTest(testCase, test); } + public static void runTestWithThrowable(@NotNull TestCase testCase, @NotNull RunnableWithThrowable test) { + MuteWithDatabaseKt.runTest(testCase, () -> { + try { + test.run(); + } + catch (Throwable throwable) { + throw new IllegalStateException(throwable); + } + return null; + }); + } + // In this test runner version the `testDataFile` parameter is annotated by `TestDataFile`. // So only file paths passed to this parameter will be used in navigation actions, like "Navigate to testdata" and "Related Symbol..." public static void runTest(DoTest test, TargetBackend targetBackend, @TestDataFile String testDataFile) throws Exception { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/RunnableWithThrowable.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/RunnableWithThrowable.java new file mode 100644 index 00000000000..acb5e6b0f68 --- /dev/null +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/RunnableWithThrowable.java @@ -0,0 +1,10 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.test; + +public interface RunnableWithThrowable { + void run() throws Throwable; +} diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinCompletionTestCase.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinCompletionTestCase.java index f7a0c6de5e3..6944baeeb22 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinCompletionTestCase.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinCompletionTestCase.java @@ -25,4 +25,10 @@ abstract public class KotlinCompletionTestCase extends CompletionTestCase { VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory()); super.tearDown(); } + + @Override + protected void runTest() throws Throwable { + //noinspection Convert2MethodRef + KotlinTestUtils.runTestWithThrowable(this, () -> super.runTest()); + } }