tests: wrap tearDown with RunAll
This commit is contained in:
+12
-3
@@ -32,6 +32,8 @@ import com.intellij.psi.search.FileTypeIndex
|
|||||||
import com.intellij.psi.search.ProjectScope
|
import com.intellij.psi.search.ProjectScope
|
||||||
import com.intellij.testFramework.LightProjectDescriptor
|
import com.intellij.testFramework.LightProjectDescriptor
|
||||||
import com.intellij.testFramework.LoggedErrorProcessor
|
import com.intellij.testFramework.LoggedErrorProcessor
|
||||||
|
import com.intellij.testFramework.RunAll
|
||||||
|
import com.intellij.util.ThrowableRunnable
|
||||||
import org.apache.log4j.Logger
|
import org.apache.log4j.Logger
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.*
|
||||||
@@ -103,9 +105,11 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun tearDown() {
|
override fun tearDown() {
|
||||||
LoggedErrorProcessor.restoreDefaultProcessor()
|
runAll(
|
||||||
disableKotlinOfficialCodeStyle(project)
|
{ LoggedErrorProcessor.restoreDefaultProcessor() },
|
||||||
super.tearDown()
|
{ disableKotlinOfficialCodeStyle(project) },
|
||||||
|
{ super.tearDown() },
|
||||||
|
)
|
||||||
|
|
||||||
if (exceptions.isNotEmpty()) {
|
if (exceptions.isNotEmpty()) {
|
||||||
exceptions.forEach { it.printStackTrace() }
|
exceptions.forEach { it.printStackTrace() }
|
||||||
@@ -323,6 +327,11 @@ fun disableKotlinOfficialCodeStyle(project: Project) {
|
|||||||
CodeStyle.getSettings(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) {
|
private fun rollbackCompilerOptions(project: Project, module: Module, removeFacet: Boolean) {
|
||||||
KotlinCompilerSettings.getInstance(project).update { this.additionalArguments = DEFAULT_ADDITIONAL_ARGUMENTS }
|
KotlinCompilerSettings.getInstance(project).update { this.additionalArguments = DEFAULT_ADDITIONAL_ARGUMENTS }
|
||||||
KotlinCommonCompilerArgumentsHolder.getInstance(project).update { this.languageVersion = LanguageVersion.LATEST_STABLE.versionString }
|
KotlinCommonCompilerArgumentsHolder.getInstance(project).update { this.languageVersion = LanguageVersion.LATEST_STABLE.versionString }
|
||||||
|
|||||||
+5
-6
@@ -23,12 +23,11 @@ abstract class KotlinLightPlatformCodeInsightFixtureTestCase : LightPlatformCode
|
|||||||
invalidateLibraryCache(project)
|
invalidateLibraryCache(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tearDown() {
|
override fun tearDown() = runAll(
|
||||||
disableKotlinOfficialCodeStyle(project)
|
{ disableKotlinOfficialCodeStyle(project) },
|
||||||
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
|
{ VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory()) },
|
||||||
|
{ super.tearDown() },
|
||||||
super.tearDown()
|
)
|
||||||
}
|
|
||||||
|
|
||||||
protected fun testDataFile(fileName: String): File = File(testDataPath, fileName)
|
protected fun testDataFile(fileName: String): File = File(testDataPath, fileName)
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -19,8 +19,8 @@ abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsight
|
|||||||
enableKotlinOfficialCodeStyle(project_)
|
enableKotlinOfficialCodeStyle(project_)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tearDown() {
|
override fun tearDown() = runAll(
|
||||||
disableKotlinOfficialCodeStyle(project_)
|
{ disableKotlinOfficialCodeStyle(project_) },
|
||||||
super.tearDown()
|
{ super.tearDown() },
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
+4
-4
@@ -20,8 +20,8 @@ abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsight
|
|||||||
enableKotlinOfficialCodeStyle(project_)
|
enableKotlinOfficialCodeStyle(project_)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tearDown() {
|
override fun tearDown() = runAll(
|
||||||
disableKotlinOfficialCodeStyle(project_)
|
{ disableKotlinOfficialCodeStyle(project_) },
|
||||||
super.tearDown()
|
{ super.tearDown() },
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
@@ -62,11 +62,11 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
|
|||||||
return moduleWithSrcRootSet
|
return moduleWithSrcRootSet
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tearDown() {
|
override fun tearDown() = runAll(
|
||||||
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
|
{ VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory()) },
|
||||||
disableKotlinOfficialCodeStyle(project)
|
{ disableKotlinOfficialCodeStyle(project) },
|
||||||
super.tearDown()
|
{ super.tearDown() },
|
||||||
}
|
)
|
||||||
|
|
||||||
public override fun createModule(path: String, moduleType: ModuleType<*>): Module {
|
public override fun createModule(path: String, moduleType: ModuleType<*>): Module {
|
||||||
return super.createModule(path, moduleType)
|
return super.createModule(path, moduleType)
|
||||||
|
|||||||
Reference in New Issue
Block a user