tests: wrap tearDown with RunAll

This commit is contained in:
Dmitry Gridin
2020-05-07 17:00:28 +07:00
parent f50e289033
commit 988c89602d
5 changed files with 30 additions and 22 deletions
@@ -32,6 +32,8 @@ import com.intellij.psi.search.FileTypeIndex
import com.intellij.psi.search.ProjectScope
import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.LoggedErrorProcessor
import com.intellij.testFramework.RunAll
import com.intellij.util.ThrowableRunnable
import org.apache.log4j.Logger
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.config.*
@@ -103,9 +105,11 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
}
override fun tearDown() {
LoggedErrorProcessor.restoreDefaultProcessor()
disableKotlinOfficialCodeStyle(project)
super.tearDown()
runAll(
{ LoggedErrorProcessor.restoreDefaultProcessor() },
{ disableKotlinOfficialCodeStyle(project) },
{ super.tearDown() },
)
if (exceptions.isNotEmpty()) {
exceptions.forEach { it.printStackTrace() }
@@ -323,6 +327,11 @@ fun disableKotlinOfficialCodeStyle(project: Project) {
CodeStyle.getSettings(project)
}
fun runAll(
vararg actions: ThrowableRunnable<Throwable>,
suppressedExceptions: List<Throwable> = emptyList()
) = RunAll(*actions).run(suppressedExceptions)
private fun rollbackCompilerOptions(project: Project, module: Module, removeFacet: Boolean) {
KotlinCompilerSettings.getInstance(project).update { this.additionalArguments = DEFAULT_ADDITIONAL_ARGUMENTS }
KotlinCommonCompilerArgumentsHolder.getInstance(project).update { this.languageVersion = LanguageVersion.LATEST_STABLE.versionString }
@@ -23,12 +23,11 @@ abstract class KotlinLightPlatformCodeInsightFixtureTestCase : LightPlatformCode
invalidateLibraryCache(project)
}
override fun tearDown() {
disableKotlinOfficialCodeStyle(project)
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
super.tearDown()
}
override fun tearDown() = runAll(
{ disableKotlinOfficialCodeStyle(project) },
{ VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory()) },
{ super.tearDown() },
)
protected fun testDataFile(fileName: String): File = File(testDataPath, fileName)
@@ -19,8 +19,8 @@ abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsight
enableKotlinOfficialCodeStyle(project_)
}
override fun tearDown() {
disableKotlinOfficialCodeStyle(project_)
super.tearDown()
}
override fun tearDown() = runAll(
{ disableKotlinOfficialCodeStyle(project_) },
{ super.tearDown() },
)
}
@@ -20,8 +20,8 @@ abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsight
enableKotlinOfficialCodeStyle(project_)
}
override fun tearDown() {
disableKotlinOfficialCodeStyle(project_)
super.tearDown()
}
override fun tearDown() = runAll(
{ disableKotlinOfficialCodeStyle(project_) },
{ super.tearDown() },
)
}
@@ -62,11 +62,11 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
return moduleWithSrcRootSet
}
override fun tearDown() {
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
disableKotlinOfficialCodeStyle(project)
super.tearDown()
}
override fun tearDown() = runAll(
{ VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory()) },
{ disableKotlinOfficialCodeStyle(project) },
{ super.tearDown() },
)
public override fun createModule(path: String, moduleType: ModuleType<*>): Module {
return super.createModule(path, moduleType)