Don't forget to rollback configured compiler options in IDE tests
This commit is contained in:
+6
-2
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.idea.completion.test.configureWithExtraFile
|
||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.configureCompilerOptions
|
||||
import org.jetbrains.kotlin.idea.test.rollbackCompilerOptions
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.indexOfOrNull
|
||||
import java.io.File
|
||||
@@ -30,11 +31,11 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
||||
|
||||
val tempSettings = CodeStyle.getSettings(project).clone()
|
||||
CodeStyle.setTemporarySettings(project, tempSettings)
|
||||
val fileText = FileUtil.loadFile(File(testPath))
|
||||
val configured = configureCompilerOptions(fileText, project, module)
|
||||
try {
|
||||
val fileText = FileUtil.loadFile(File(testPath))
|
||||
assertTrue("\"<caret>\" is missing in file \"$testPath\"", fileText.contains("<caret>"));
|
||||
|
||||
configureCompilerOptions(fileText, project, module)
|
||||
|
||||
val invocationCount = InTextDirectivesUtils.getPrefixedInt(fileText, INVOCATION_COUNT_PREFIX) ?: 1
|
||||
val lookupString = InTextDirectivesUtils.findStringWithPrefixes(fileText, LOOKUP_STRING_PREFIX)
|
||||
@@ -71,6 +72,9 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
||||
|
||||
doTestWithTextLoaded(completionType, invocationCount, lookupString, itemText, tailText, completionChar, File(testPath).name + ".after")
|
||||
} finally {
|
||||
if (configured) {
|
||||
rollbackCompilerOptions(project, module)
|
||||
}
|
||||
CodeStyle.dropTemporarySettings(project)
|
||||
tearDownFixture()
|
||||
}
|
||||
|
||||
+10
-3
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.idea.completion.test.configureWithExtraFile
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.configureCompilerOptions
|
||||
import org.jetbrains.kotlin.idea.test.rollbackCompilerOptions
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.junit.Assert
|
||||
|
||||
@@ -24,13 +25,19 @@ abstract class AbstractCompletionWeigherTest(val completionType: CompletionType,
|
||||
|
||||
val text = myFixture.editor.document.text
|
||||
|
||||
configureCompilerOptions(text, project, module)
|
||||
val configured = configureCompilerOptions(text, project, module)
|
||||
|
||||
val items = InTextDirectivesUtils.findArrayWithPrefixes(text, "// ORDER:")
|
||||
Assert.assertTrue("""Some items should be defined with "// ORDER:" directive""", !items.isEmpty())
|
||||
|
||||
myFixture.complete(completionType, InTextDirectivesUtils.getPrefixedInt(text, "// INVOCATION_COUNT:") ?: 1)
|
||||
myFixture.assertPreferredCompletionItems(InTextDirectivesUtils.getPrefixedInt(text, "// SELECTED:") ?: 0, *items)
|
||||
try {
|
||||
myFixture.complete(completionType, InTextDirectivesUtils.getPrefixedInt(text, "// INVOCATION_COUNT:") ?: 1)
|
||||
myFixture.assertPreferredCompletionItems(InTextDirectivesUtils.getPrefixedInt(text, "// SELECTED:") ?: 0, *items)
|
||||
} finally {
|
||||
if (configured) {
|
||||
rollbackCompilerOptions(project, module)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user