Checking exceptions in other threads. E.g. inspections pass thread.

This commit is contained in:
Evgeny Gerashchenko
2015-06-27 15:13:02 +03:00
parent bae9a7d7f8
commit 560654744c
@@ -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<Throwable>()
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<EditorTracker>())?.projectOpened()
LoggedErrorProcessor.setNewInstance(object : LoggedErrorProcessor() {
override fun processError(message: String?, t: Throwable?, details: Array<out String>?, 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