From bcf29e6fbf2ab9d23d3b6ea298923834be00e050 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 24 Jan 2017 19:08:18 +0300 Subject: [PATCH] Run tests in read action and not in EDT thread Otherwise test will fail because of runInReadActionWithWriteActionPriority call in EDT --- ...AbstractBeforeExtractFunctionInsertionTest.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractBeforeExtractFunctionInsertionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractBeforeExtractFunctionInsertionTest.kt index e0d5392d1da..577c4909333 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractBeforeExtractFunctionInsertionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractBeforeExtractFunctionInsertionTest.kt @@ -16,16 +16,20 @@ package org.jetbrains.kotlin.idea.debugger +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.application.runReadAction import com.intellij.openapi.util.io.FileUtil import com.intellij.testFramework.LightCodeInsightTestCase import com.intellij.testFramework.LightPlatformCodeInsightTestCase import org.jetbrains.kotlin.idea.refactoring.getLineNumber import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinCodeFragmentFactory import org.jetbrains.kotlin.idea.debugger.evaluate.addDebugExpressionIntoTmpFileForExtractFunction +import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtExpressionCodeFragment import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File +import java.util.concurrent.Callable abstract class AbstractBeforeExtractFunctionInsertionTest : LightCodeInsightTestCase() { @@ -42,10 +46,14 @@ abstract class AbstractBeforeExtractFunctionInsertionTest : LightCodeInsightTest val allText = fragmentFile.text val fragmentText = if (imports.isBlank()) allText else allText.substringAfter(imports, allText) - val expressionList = addDebugExpressionIntoTmpFileForExtractFunction( - myFile as KtFile, - KtExpressionCodeFragment(getProject(), "fragment.kt", fragmentText, imports, elementAt), - line) + val expressionList = ApplicationManager.getApplication().executeOnPooledThread(Callable> { + runReadAction { + addDebugExpressionIntoTmpFileForExtractFunction( + myFile as KtFile, + KtExpressionCodeFragment(getProject(), "fragment.kt", fragmentText, imports, elementAt), + line) + } + }).get() KotlinTestUtils.assertEqualsToFile(File(path + ".after"), expressionList.first().containingFile.text) }