Now possible to use // WITH_RUNTIME in multi file tests

This commit is contained in:
Simon Ogorodnik
2016-08-31 00:20:22 +03:00
committed by Dmitry Jemerov
parent da2ebb1394
commit b06bdcef75
@@ -232,6 +232,12 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
protected void doMultiFileTest(final String beforeFileName) throws Exception { protected void doMultiFileTest(final String beforeFileName) throws Exception {
String multifileText = FileUtil.loadFile(new File(beforeFileName), true); String multifileText = FileUtil.loadFile(new File(beforeFileName), true);
boolean withRuntime = InTextDirectivesUtils.isDirectiveDefined(multifileText, "// WITH_RUNTIME");
if (withRuntime) {
ConfigLibraryUtil.configureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk());
}
try {
final List<TestFile> subFiles = KotlinTestUtils.createTestFiles( final List<TestFile> subFiles = KotlinTestUtils.createTestFiles(
"single.kt", "single.kt",
multifileText, multifileText,
@@ -289,7 +295,8 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
doAction(text, actionShouldBeAvailable, getTestName(false)); doAction(text, actionShouldBeAvailable, getTestName(false));
String actualText = getFile().getText(); String actualText = getFile().getText();
String afterText = new StringBuilder(actualText).insert(getEditor().getCaretModel().getOffset(), "<caret>").toString(); String afterText =
new StringBuilder(actualText).insert(getEditor().getCaretModel().getOffset(), "<caret>").toString();
if (pair.second) { if (pair.second) {
assertNotNull(".after file should exist", afterFile); assertNotNull(".after file should exist", afterFile);
@@ -321,6 +328,12 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
} }
}, "", ""); }, "", "");
} }
finally {
if (withRuntime) {
ConfigLibraryUtil.unConfigureKotlinRuntimeAndSdk(myModule, PluginTestCaseBase.mockJdk());
}
}
}
private void doTest(final String beforeFileName, boolean withExtraFile) throws Exception { private void doTest(final String beforeFileName, boolean withExtraFile) throws Exception {
String testDataPath = getTestDataPath(); String testDataPath = getTestDataPath();