Check no runtime markers are misused in quick fix tests

(cherry picked from commit bab26d4)
This commit is contained in:
Nikolay Krasko
2016-11-29 18:36:04 +03:00
committed by Nikolay Krasko
parent dbe32b98ef
commit 57964845ad
@@ -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<String, Boolean> 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<String> validActions = new HashSet<String>(InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "// ACTION:"));
final Set<String> validActions =
new HashSet<String>(InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "// ACTION:"));
CollectionsKt.removeAll(actions, new Function1<IntentionAction, Boolean>() {
@Override