From 57964845ad09dd8eb370cd8287786a0d4ca94dea Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 29 Nov 2016 18:36:04 +0300 Subject: [PATCH] Check no runtime markers are misused in quick fix tests (cherry picked from commit bab26d4) --- .../kotlin/idea/quickfix/AbstractQuickFixTest.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.java index 41dfea190d1..a03add55fbb 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.java @@ -172,7 +172,8 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase { e.printStackTrace(); fail(testName); } - } finally { + } + finally { for (String fixtureClass : fixtureClasses) { TestFixtureExtension.Companion.unloadFixture(fixtureClass); } @@ -182,7 +183,8 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase { }, "", ""); } - private static void applyAction(String contents, QuickFixTestCase quickFixTestCase, String testName, String testFullPath) throws Exception { + private static void applyAction(String contents, QuickFixTestCase quickFixTestCase, String testName, String testFullPath) + throws Exception { Pair pair = quickFixTestCase.parseActionHintImpl(quickFixTestCase.getFile(), contents); String fileName = StringsKt.substringAfterLast(testFullPath, "/", ""); @@ -229,6 +231,10 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase { else if (isRuntimeNeeded(beforeFileName)) { ConfigLibraryUtil.configureKotlinRuntimeAndSdk(getModule(), getFullJavaJDK()); } + else if (beforeFileName.contains("Runtime") || beforeFileName.contains("JsRuntime")) { + Assert.fail("Runtime marker is used in test name, but not in test file end. " + + "This can lead to false-positive absent of actions"); + } } private static boolean isRuntimeNeeded(@NotNull String beforeFileName) throws IOException { @@ -267,7 +273,8 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase { final Class aClass = Class.forName(className); assert IntentionAction.class.isAssignableFrom(aClass) : className + " should be inheritor of IntentionAction"; - final Set validActions = new HashSet(InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "// ACTION:")); + final Set validActions = + new HashSet(InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "// ACTION:")); CollectionsKt.removeAll(actions, new Function1() { @Override