diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/JetLightCodeInsightFixtureTestCase.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/JetLightCodeInsightFixtureTestCase.kt index 16ac9cfa65f..bdf09937a7b 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/JetLightCodeInsightFixtureTestCase.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/JetLightCodeInsightFixtureTestCase.kt @@ -28,17 +28,23 @@ import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess import com.intellij.testFramework.LightProjectDescriptor +import com.intellij.testFramework.LoggedErrorProcessor import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import org.apache.log4j.Logger import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.JetTestUtils +import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.rethrow import java.io.File import java.io.IOException +import java.util.* public abstract class JetLightCodeInsightFixtureTestCase : LightCodeInsightFixtureTestCase() { private var kotlinInternalModeOriginalValue = false + private val exceptions = ArrayList() + override fun setUp() { super.setUp() (StartupManager.getInstance(getProject()) as StartupManagerImpl).runPostStartupActivities() @@ -48,15 +54,29 @@ public abstract class JetLightCodeInsightFixtureTestCase : LightCodeInsightFixtu KotlinInternalMode.enabled = true getProject().getComponent(javaClass())?.projectOpened() + + LoggedErrorProcessor.setNewInstance(object : LoggedErrorProcessor() { + override fun processError(message: String?, t: Throwable?, details: Array?, logger: Logger) { + exceptions.addIfNotNull(t) + super.processError(message, t, details, logger) + } + }) } override fun tearDown() { + LoggedErrorProcessor.restoreDefaultProcessor() + KotlinInternalMode.enabled = kotlinInternalModeOriginalValue VfsRootAccess.disallowRootAccess(JetTestUtils.getHomeDirectory()) unInvalidateBuiltins(getProject()) { super.tearDown() } + + if (exceptions.isNotEmpty()) { + exceptions.forEach { it.printStackTrace() } + throw AssertionError("Exceptions in other threads happened") + } } override fun getProjectDescriptor(): LightProjectDescriptor