From 5d9bdbec109f791ca1f21c0b206c47a7b3518750 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Fri, 23 Mar 2018 23:11:26 +0300 Subject: [PATCH] Tests: Disable inspections after test as Platform test framework requires --- .../idea/quickfix/AbstractQuickFixTest.kt | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.kt index dea09422653..d30052f20cf 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.kt @@ -26,10 +26,7 @@ import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.CharsetToolkit import com.intellij.rt.execution.junit.FileComparisonFailure -import com.intellij.testFramework.InspectionTestUtil -import com.intellij.testFramework.LightPlatformTestCase -import com.intellij.testFramework.LightProjectDescriptor -import com.intellij.testFramework.UsefulTestCase +import com.intellij.testFramework.* import com.intellij.util.ui.UIUtil import junit.framework.TestCase import org.jetbrains.kotlin.idea.quickfix.utils.findInspectionFile @@ -46,10 +43,16 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase() { val beforeFileText = FileUtil.loadFile(File(beforeFileName)) configureLanguageVersion(beforeFileText, project, module) - enableInspections(beforeFileName, beforeFileText) + val inspections = parceInspectionsToEnable(beforeFileName, beforeFileText).toTypedArray() - doKotlinQuickFixTest(beforeFileName) - checkForUnexpectedErrors() + try { + myFixture.enableInspections(*inspections) + + doKotlinQuickFixTest(beforeFileName) + checkForUnexpectedErrors() + } finally { + myFixture.disableInspections(*inspections) + } } override fun getProjectDescriptor(): LightProjectDescriptor { @@ -160,7 +163,7 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase() { } } - private fun enableInspections(beforeFileName: String, beforeFileText: String) { + private fun parceInspectionsToEnable(beforeFileName: String, beforeFileText: String): List { val toolsStrings = InTextDirectivesUtils.findListWithPrefixes(beforeFileText, "TOOL:") if (toolsStrings.isNotEmpty()) { val inspections = toolsStrings.map { toolFqName -> @@ -172,18 +175,17 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase() { throw IllegalArgumentException("Failed to create inspection for key '$toolFqName'", e) } } - myFixture.enableInspections(*inspections.toTypedArray()) - return + return inspections } val inspectionFile = findInspectionFile(File(beforeFileName).parentFile) if (inspectionFile != null) { val className = FileUtil.loadFile(inspectionFile).trim { it <= ' ' } val inspectionClass = Class.forName(className) as Class - val tools = InspectionTestUtil.instantiateTools( - listOf>(inspectionClass)) - myFixture.enableInspections(*tools.toTypedArray()) + return InspectionTestUtil.instantiateTools(listOf>(inspectionClass)) } + + return emptyList() } @Throws(ClassNotFoundException::class)