IJPL-578 [Kotlin] Fix Kotlin debugger evaluation tests with .kts after changes in previous commits

The problem was that the first evaluation triggers script configuration initialization,
which in turn calls `ScriptClassRootsUpdater#applyDiffToModel`, and test doesn't wait
until the end of this update, which leads to an exception.

GitOrigin-RevId: 17c1e25f8df843670be1d4c77e5eb24d72b02a6b
This commit is contained in:
Roman Efremov
2024-03-14 14:22:35 +00:00
committed by intellij-monorepo-bot
parent 0c59c0441d
commit a046ab5148
2 changed files with 11 additions and 0 deletions
@@ -32,6 +32,7 @@
<orderEntry type="module" module-name="kotlin.base.code-insight" scope="TEST" />
<orderEntry type="module" module-name="kotlin.base.test" />
<orderEntry type="module" module-name="kotlin.base.fe10.analysis" />
<orderEntry type="module" module-name="kotlin.base.scripting" scope="TEST" />
<orderEntry type="module" module-name="kotlin.core" scope="TEST" />
<orderEntry type="module" module-name="kotlin.fir.frontend-independent" scope="TEST" />
<orderEntry type="module" module-name="kotlin.tests-common" scope="TEST" />
@@ -4,9 +4,12 @@ package org.jetbrains.kotlin.idea.debugger.test
import com.intellij.execution.configurations.JavaParameters
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.doWriteAction
import com.intellij.testFramework.PsiTestUtil
import com.intellij.testFramework.runInEdtAndWait
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.config.JvmClosureGenerationScheme
import org.jetbrains.kotlin.idea.base.plugin.artifacts.TestKotlinArtifacts
import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager
import org.jetbrains.kotlin.idea.debugger.test.preference.DebuggerPreferences
import org.jetbrains.kotlin.idea.test.KotlinCliCompilerFacade
import org.jetbrains.kotlin.psi.KtFile
import java.io.File
@@ -22,6 +25,13 @@ abstract class AbstractIrKotlinScriptEvaluateExpressionTest : AbstractIrKotlinEv
}
}
override fun doMultiFileTest(files: TestFiles, preferences: DebuggerPreferences) {
// Warm up the script configuration, otherwise it will be initialized during evaluation
// which leads to "Evaluation is not possible during indexing" exception
runInEdtAndWait { ScriptConfigurationManager.updateScriptDependenciesSynchronously(getScriptKtFile()) }
super.doMultiFileTest(files, preferences)
}
override fun createBreakpoints(className: String?) = super.createBreakpoints(getScriptKtFile())
override fun getMainClassName(compilerFacility: DebuggerTestCompilerFacility) = K2JVMCompiler::class.qualifiedName!!