From 970ff60e8ebd300f80c3ac4815c13a7bbd4007f9 Mon Sep 17 00:00:00 2001 From: Bart van Helvert Date: Wed, 15 Jun 2022 15:50:54 +0200 Subject: [PATCH] Properly teardown test methods Moves `super.tearDown` into a finally clause such that it gets executed even when an exception is thrown before it gets called. GitOrigin-RevId: 51b257ada3a916ec5a8462445e67db50c86852bb --- .../artifacts/workspaceModel/ArtifactTest.kt | 14 +++++-- .../InlineModuleDependencyActionTest.kt | 13 +++++-- .../JavaLibraryRootsDetectionTest.kt | 14 +++++-- .../ConvertToRepositoryLibraryActionTest.kt | 27 +++++-------- .../AbstractParameterInfoTestCase.java | 13 +++++-- .../daemon/inlays/IntentionTest.kt | 16 +++++--- .../inlays/JavaParameterNameHintsTest.kt | 29 ++++++-------- .../problems/ProjectProblemsViewTest.kt | 11 +++++- .../problems/SplitEditorProblemsTest.kt | 13 +++++-- .../daemon/quickFix/I18nQuickFixTest.java | 15 +++++-- .../navigation/NestedClassLineMarkerTest.java | 15 +++++-- .../navigation/RunLineMarkerTest.java | 15 +++++-- .../InspectionResultViewTest.kt | 15 +++++-- .../fileTemplates/impl/FileTemplatesTest.kt | 12 ++++-- .../codeStyle/IndentOptionsCacheDropTest.kt | 28 +++++-------- .../ExtractMethodAndDuplicatesInplaceTest.kt | 16 +++++--- .../InplaceIntroduceConstantTest.java | 13 +++++-- ...tJava9ModulesCodeInsightFixtureTestCase.kt | 11 +++++- .../command/undo/MultiUserEditorUndoTest.java | 13 +++++-- .../projectView/AbstractProjectViewTest.kt | 19 +++++---- .../projectView/CustomScopePaneTest.kt | 13 +++++-- .../util/indexing/IndexDiagnosticTest.kt | 14 +++++-- ...SuggestedRefactoringChangeCollectorTest.kt | 13 +++++-- ...eSuggestedRefactoringChangeListenerTest.kt | 13 +++++-- .../jps/builders/ParallelBuildTest.kt | 13 +++++-- .../artifacts/ArtifactBuilderTestCase.java | 19 ++++++--- .../CompilerEncodingConfigurationTest.java | 27 +++++-------- .../references/ReferenceIndexTestBase.kt | 13 +++++-- .../testSrc/com/intellij/diff/DiffTestCase.kt | 24 ++++-------- .../com/intellij/diff/HeavyDiffTestCase.kt | 17 +------- .../autoimport/AutoImportTestCase.kt | 19 ++++++--- .../autolink/AutoLinkTestCase.kt | 15 +++++-- .../manage/ExternalProjectsDataStorageTest.kt | 13 +++++-- .../ExternalSystemJdkComboBoxUtilTestCase.kt | 17 +++++--- .../intellij/application/TransactionTest.kt | 15 +++++-- .../CompositeValidationRulesStorageTest.kt | 15 +++++-- .../storage/ValidationRulesBaseStorageTest.kt | 28 +++++++------ .../CompoundParallelOperationTraceTestCase.kt | 10 +++-- .../sm/runner/BaseSMTRunnerTestCase.java | 15 +++++-- ...GeneralToSMTRunnerEventsConvertorTest.java | 21 ++++++---- .../sm/runner/TestSuiteStackTest.java | 28 +++++-------- .../sm/runner/ui/SMTRunnerFiltersTest.java | 37 +++++++----------- .../ui/SMTRunnerUIActionsHandlerTest.java | 29 ++++++-------- .../ui/SMTestRunnerResultsFormTest.java | 30 ++++++-------- .../src/com/intellij/FileSetTestCase.java | 13 +++++-- .../testFramework/FlyIdeaTestCase.java | 14 ++++--- .../EditorConfigEncodingInspectionTest.java | 11 +++++- .../commands/GitHttpGuiAuthenticatorTest.kt | 25 ++++++------ .../git4idea/index/GitIndexStatusTest.kt | 15 +++++-- .../git4idea/index/GitStageTrackerTest.kt | 19 ++++++--- .../tests/git4idea/log/GitLogIndexTest.kt | 13 +++++-- .../importing/GradleSetupProjectTest.kt | 16 +++++--- .../com/intellij/grazie/GrazieTestBase.kt | 11 +++++- ...oovyParameterTypeHintsInlayProviderTest.kt | 11 +++++- .../featuresSuggester/FeatureSuggesterTest.kt | 13 +++++-- .../impl/PropertiesContextFoldingTest.java | 13 +++++-- .../artifacts/LazyFileOutputProducerTest.kt | 9 +++-- .../AbstractSerializationQuickFixTest.kt | 14 ++++--- .../ide/test/AbstractParcelizeCheckerTest.kt | 11 ++++-- .../ide/test/AbstractParcelizeQuickFixTest.kt | 11 ++++-- ...eModulesPerSourceSetInMppBuildIssueTest.kt | 16 +++++--- .../gradle/KotlinGradleImportingTestCase.kt | 11 ++++-- ...solveModulePerSourceSetNotificationTest.kt | 17 +++++--- .../KotlinChangeSignatureTest.kt | 15 ++++--- .../kotlin/idea/run/KotlinJUnitLightTest.kt | 13 +++++-- .../AbstractKotlinEvaluateExpressionTest.kt | 11 ++++-- .../KotlinDescriptorTestCaseWithStepping.kt | 11 ++++-- .../kotlin/idea/codegen/CodegenTestCase.java | 39 +++++++++---------- .../testFramework/KtPlatformLiteFixture.java | 13 +++++-- .../editor/tables/MarkdownTableTabTest.kt | 11 +++++- .../formatter/MarkdownFormatterTest.kt | 25 +++++++----- ...hEverywhereBaseFileFeaturesProviderTest.kt | 13 +++++-- .../stats/completion/storage/StorageTest.kt | 23 ++++------- .../ide/annotator/TomlAnnotationTestBase.kt | 9 ++++- .../ide/completion/TomlCompletionTestBase.kt | 9 ++++- .../jetbrains/python/PyPackageIconTest.java | 13 +++++-- .../PyTestCreationModelTest.kt | 18 ++++++--- .../console/PyConsoleEnterHandlerTest.kt | 14 +++++-- .../PyRelativeImportInspectionTest.kt | 13 +++++-- 79 files changed, 802 insertions(+), 491 deletions(-) diff --git a/java/compiler/tests/com/intellij/compiler/artifacts/workspaceModel/ArtifactTest.kt b/java/compiler/tests/com/intellij/compiler/artifacts/workspaceModel/ArtifactTest.kt index 170776fa09b2..09e19e574435 100644 --- a/java/compiler/tests/com/intellij/compiler/artifacts/workspaceModel/ArtifactTest.kt +++ b/java/compiler/tests/com/intellij/compiler/artifacts/workspaceModel/ArtifactTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.compiler.artifacts.workspaceModel import com.intellij.compiler.artifacts.ArtifactsTestCase @@ -41,7 +41,6 @@ import com.intellij.workspaceModel.storage.bridgeEntities.api.ArtifactProperties import com.intellij.workspaceModel.storage.bridgeEntities.api.ArtifactRootElementEntity import com.intellij.workspaceModel.storage.url.VirtualFileUrlManager import junit.framework.TestCase -import com.intellij.workspaceModel.storage.bridgeEntities.api.modifyEntity import org.junit.Assume.assumeTrue import org.junit.runner.RunWith import java.util.concurrent.Callable @@ -50,8 +49,15 @@ import java.util.concurrent.Callable class ArtifactTest : ArtifactsTestCase() { override fun tearDown() { - ArtifactsTestingState.reset() - super.tearDown() + try { + ArtifactsTestingState.reset() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun `test rename artifact via model`() = runWriteAction { diff --git a/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/classpath/InlineModuleDependencyActionTest.kt b/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/classpath/InlineModuleDependencyActionTest.kt index 10504fdcfb8e..f8dff2bfe83b 100644 --- a/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/classpath/InlineModuleDependencyActionTest.kt +++ b/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/classpath/InlineModuleDependencyActionTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.roots.ui.configuration.classpath import com.intellij.openapi.application.WriteAction @@ -15,8 +15,15 @@ import junit.framework.TestCase class InlineModuleDependencyActionTest : JavaModuleTestCase() { override fun tearDown() { - ProjectStructureConfigurable.getInstance(myProject).context.modulesConfigurator.disposeUIResources() - super.tearDown() + try { + ProjectStructureConfigurable.getInstance(myProject).context.modulesConfigurator.disposeUIResources() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun `test inline module with module library`() { diff --git a/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavaLibraryRootsDetectionTest.kt b/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavaLibraryRootsDetectionTest.kt index 20345d44cae2..7d09739cfc97 100644 --- a/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavaLibraryRootsDetectionTest.kt +++ b/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavaLibraryRootsDetectionTest.kt @@ -1,9 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.roots.ui.configuration.libraryEditor import com.intellij.ide.highlighter.ArchiveFileType import com.intellij.openapi.fileTypes.FileTypeRegistry -import com.intellij.openapi.fileTypes.StdFileTypes import com.intellij.openapi.progress.EmptyProgressIndicator import com.intellij.openapi.roots.NativeLibraryOrderRootType import com.intellij.openapi.roots.OrderRootType @@ -89,7 +88,14 @@ class JavaLibraryRootsDetectionTest : LightPlatformTestCase() { } override fun tearDown() { - JarFileSystemImpl.cleanupForNextTest() - super.tearDown() + try { + JarFileSystemImpl.cleanupForNextTest() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } } \ No newline at end of file diff --git a/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionTest.kt b/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionTest.kt index 70282f52a7d5..28eb2a933e54 100644 --- a/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionTest.kt +++ b/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionTest.kt @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.roots.ui.configuration.projectRoot import com.intellij.openapi.vfs.JarFileSystem @@ -79,7 +65,14 @@ class ConvertToRepositoryLibraryActionTest : LightPlatformTestCase() { } override fun tearDown() { - JarFileSystemImpl.cleanupForNextTest() - super.tearDown() + try { + JarFileSystemImpl.cleanupForNextTest() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/AbstractParameterInfoTestCase.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/AbstractParameterInfoTestCase.java index a304f55f68bd..96368f700a69 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/AbstractParameterInfoTestCase.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/AbstractParameterInfoTestCase.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.codeInsight; import com.intellij.codeInsight.AutoPopupController; @@ -38,8 +38,15 @@ public abstract class AbstractParameterInfoTestCase extends LightFixtureCompleti @Override protected void tearDown() throws Exception { - CodeInsightSettings.getInstance().PARAMETER_INFO_DELAY = myStoredAutoPopupDelay; - super.tearDown(); + try { + CodeInsightSettings.getInstance().PARAMETER_INFO_DELAY = myStoredAutoPopupDelay; + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } protected void configureJava(String text) { diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/IntentionTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/IntentionTest.kt index 30e8c3a23860..3dd6eaeb5c87 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/IntentionTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/IntentionTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.codeInsight.daemon.inlays import com.intellij.codeInsight.hints.settings.ParameterNameHintsSettings @@ -21,10 +21,16 @@ class BlackListMethodIntentionTest : LightJavaCodeInsightFixtureTestCase() { } override fun tearDown() { - EditorSettingsExternalizable.getInstance().isShowParameterNameHints = isParamHintsEnabledBefore - ParameterNameHintsSettings.getInstance().loadState(default.state) - - super.tearDown() + try { + EditorSettingsExternalizable.getInstance().isShowParameterNameHints = isParamHintsEnabledBefore + ParameterNameHintsSettings.getInstance().loadState(default.state) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun `test add to blacklist by alt enter`() { diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt index 744bfe627f4f..6036d467b0a9 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.codeInsight.daemon.inlays import com.intellij.codeInsight.daemon.impl.ParameterHintsPresentationManager @@ -33,9 +19,16 @@ class JavaInlayParameterHintsTest : LightJavaCodeInsightFixtureTestCase() { } override fun tearDown() { - val default = ParameterNameHintsSettings() - ParameterNameHintsSettings.getInstance().loadState(default.state) - super.tearDown() + try { + val default = ParameterNameHintsSettings() + ParameterNameHintsSettings.getInstance().loadState(default.state) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun check(text: String) { diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/problems/ProjectProblemsViewTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/problems/ProjectProblemsViewTest.kt index 6e25d23d7a57..46b7a66653c3 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/problems/ProjectProblemsViewTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/problems/ProjectProblemsViewTest.kt @@ -28,8 +28,15 @@ internal abstract class ProjectProblemsViewTest : LightJavaCodeInsightFixtureTes } override fun tearDown() { - project.putUserData(CodeVisionHost.isCodeVisionTestKey, null) - super.tearDown() + try { + project.putUserData(CodeVisionHost.isCodeVisionTestKey, null) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } override fun getProjectDescriptor(): LightProjectDescriptor { diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/problems/SplitEditorProblemsTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/problems/SplitEditorProblemsTest.kt index 35de78cfbfe9..2389090e2040 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/problems/SplitEditorProblemsTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/problems/SplitEditorProblemsTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.codeInsight.daemon.problems import com.intellij.codeInsight.codeVision.CodeVisionHost @@ -33,8 +33,15 @@ internal class SplitEditorProblemsTest : ProjectProblemsViewTest() { } override fun tearDown() { - project.putUserData(CodeVisionHost.isCodeVisionTestKey, null) - super.tearDown() + try { + project.putUserData(CodeVisionHost.isCodeVisionTestKey, null) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun testClassRenameInTwoDetachedWindows() { diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/I18nQuickFixTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/I18nQuickFixTest.java index 5151b2ba18c3..2e871cf3b54a 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/I18nQuickFixTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/I18nQuickFixTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.codeInsight.daemon.quickFix; import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; @@ -34,9 +34,16 @@ public class I18nQuickFixTest extends LightQuickFixParameterizedTestCase { @Override protected void tearDown() throws Exception { - // avoid "memory/disk conflict" when the document for changed annotation.xml stays in memory - ((PsiDocumentManagerBase)PsiDocumentManager.getInstance(getProject())).clearUncommittedDocuments(); - super.tearDown(); + try { + // avoid "memory/disk conflict" when the document for changed annotation.xml stays in memory + ((PsiDocumentManagerBase)PsiDocumentManager.getInstance(getProject())).clearUncommittedDocuments(); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } @Override diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/NestedClassLineMarkerTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/NestedClassLineMarkerTest.java index 44ba00bbf43d..95082801b9cb 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/NestedClassLineMarkerTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/NestedClassLineMarkerTest.java @@ -24,11 +24,18 @@ public class NestedClassLineMarkerTest extends LightJavaCodeInsightFixtureTestCa private final Set myTempSettings = new HashSet<>(); @Override protected void tearDown() throws Exception { - RunManager runManager = RunManager.getInstance(getProject()); - for (RunnerAndConfigurationSettings setting : myTempSettings) { - runManager.removeConfiguration(setting); + try { + RunManager runManager = RunManager.getInstance(getProject()); + for (RunnerAndConfigurationSettings setting : myTempSettings) { + runManager.removeConfiguration(setting); + } + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); } - super.tearDown(); } @Override diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/RunLineMarkerTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/RunLineMarkerTest.java index d53a7a5dfbe9..efa0d3691b14 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/RunLineMarkerTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/navigation/RunLineMarkerTest.java @@ -47,11 +47,18 @@ public class RunLineMarkerTest extends LightJavaCodeInsightFixtureTestCase { private final Set myTempSettings = new HashSet<>(); @Override protected void tearDown() throws Exception { - RunManager runManager = RunManager.getInstance(getProject()); - for (RunnerAndConfigurationSettings setting : myTempSettings) { - runManager.removeConfiguration(setting); + try { + RunManager runManager = RunManager.getInstance(getProject()); + for (RunnerAndConfigurationSettings setting : myTempSettings) { + runManager.removeConfiguration(setting); + } + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); } - super.tearDown(); } public void testRunLineMarker() { diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/InspectionResultViewTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInspection/InspectionResultViewTest.kt index 90b8629d8eeb..da2eab9f71e4 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/InspectionResultViewTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/InspectionResultViewTest.kt @@ -29,10 +29,17 @@ class InspectionResultViewTest : LightJava9ModulesCodeInsightFixtureTestCase() { } public override fun tearDown() { - GlobalInspectionContextImpl.TESTING_VIEW = false - InspectionProfileImpl.INIT_INSPECTIONS = false - AnalysisUIOptions.getInstance(project).SHOW_STRUCTURE = myDefaultShowStructure - super.tearDown() + try { + GlobalInspectionContextImpl.TESTING_VIEW = false + InspectionProfileImpl.INIT_INSPECTIONS = false + AnalysisUIOptions.getInstance(project).SHOW_STRUCTURE = myDefaultShowStructure + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun testModuleInfoProblemsTree() { diff --git a/java/java-tests/testSrc/com/intellij/java/ide/fileTemplates/impl/FileTemplatesTest.kt b/java/java-tests/testSrc/com/intellij/java/ide/fileTemplates/impl/FileTemplatesTest.kt index 6faf430a650d..25e673d4a451 100644 --- a/java/java-tests/testSrc/com/intellij/java/ide/fileTemplates/impl/FileTemplatesTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/ide/fileTemplates/impl/FileTemplatesTest.kt @@ -32,9 +32,15 @@ internal class FileTemplatesTest : JavaProjectTestCase() { private var testConfigDir: Path? = null override fun tearDown() { - super.tearDown() - - testConfigDir?.delete() + try { + testConfigDir?.delete() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun testAllTemplates() { diff --git a/java/java-tests/testSrc/com/intellij/java/psi/codeStyle/IndentOptionsCacheDropTest.kt b/java/java-tests/testSrc/com/intellij/java/psi/codeStyle/IndentOptionsCacheDropTest.kt index 02920367f1df..9836cdcfb23e 100644 --- a/java/java-tests/testSrc/com/intellij/java/psi/codeStyle/IndentOptionsCacheDropTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/psi/codeStyle/IndentOptionsCacheDropTest.kt @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.psi.codeStyle @@ -40,9 +26,15 @@ class IndentOptionsCacheDropTest: LightJavaCodeInsightFixtureTestCase() { } override fun tearDown() { - val instance = DetectableIndentOptionsProvider.getInstance() - instance?.setEnabledInTest(false) - super.tearDown() + try { + DetectableIndentOptionsProvider.getInstance()?.setEnabledInTest(false) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } val code = """ diff --git a/java/java-tests/testSrc/com/intellij/java/refactoring/ExtractMethodAndDuplicatesInplaceTest.kt b/java/java-tests/testSrc/com/intellij/java/refactoring/ExtractMethodAndDuplicatesInplaceTest.kt index 81cdb30a6b41..73c572672650 100644 --- a/java/java-tests/testSrc/com/intellij/java/refactoring/ExtractMethodAndDuplicatesInplaceTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/refactoring/ExtractMethodAndDuplicatesInplaceTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.refactoring import com.intellij.codeInsight.template.impl.TemplateManagerImpl @@ -297,9 +297,15 @@ class ExtractMethodAndDuplicatesInplaceTest: LightJavaCodeInsightTestCase() { } override fun tearDown() { - val template = getActiveTemplate() - if (template != null) Disposer.dispose(template) - super.tearDown() + try { + val template = getActiveTemplate() + if (template != null) Disposer.dispose(template) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } - } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/refactoring/InplaceIntroduceConstantTest.java b/java/java-tests/testSrc/com/intellij/java/refactoring/InplaceIntroduceConstantTest.java index 52cf71b5588d..5514b2f118e2 100644 --- a/java/java-tests/testSrc/com/intellij/java/refactoring/InplaceIntroduceConstantTest.java +++ b/java/java-tests/testSrc/com/intellij/java/refactoring/InplaceIntroduceConstantTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.refactoring; import com.intellij.openapi.editor.Editor; @@ -21,8 +21,15 @@ public class InplaceIntroduceConstantTest extends AbstractJavaInplaceIntroduceTe @Override protected void tearDown() throws Exception { - super.tearDown(); - JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_REPLACE_ALL = false; + try { + JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_REPLACE_ALL = false; + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } public void testReplaceAll() { diff --git a/java/java-tests/testSrc/com/intellij/java/testFramework/fixtures/LightJava9ModulesCodeInsightFixtureTestCase.kt b/java/java-tests/testSrc/com/intellij/java/testFramework/fixtures/LightJava9ModulesCodeInsightFixtureTestCase.kt index 77cead76533e..f3229fdad9d7 100644 --- a/java/java-tests/testSrc/com/intellij/java/testFramework/fixtures/LightJava9ModulesCodeInsightFixtureTestCase.kt +++ b/java/java-tests/testSrc/com/intellij/java/testFramework/fixtures/LightJava9ModulesCodeInsightFixtureTestCase.kt @@ -18,8 +18,15 @@ abstract class LightJava9ModulesCodeInsightFixtureTestCase : LightJavaCodeInsigh override fun getProjectDescriptor(): LightProjectDescriptor = MultiModuleJava9ProjectDescriptor override fun tearDown() { - super.tearDown() - MultiModuleJava9ProjectDescriptor.cleanupSourceRoots() + try { + MultiModuleJava9ProjectDescriptor.cleanupSourceRoots() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } protected fun addFile(path: String, text: String, module: ModuleDescriptor = MAIN): VirtualFile = diff --git a/java/java-tests/testSrc/com/intellij/openapi/command/undo/MultiUserEditorUndoTest.java b/java/java-tests/testSrc/com/intellij/openapi/command/undo/MultiUserEditorUndoTest.java index b15760b8c4ff..fc3ca6350a46 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/command/undo/MultiUserEditorUndoTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/command/undo/MultiUserEditorUndoTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.command.undo; import com.intellij.codeWithMe.ClientId; @@ -40,8 +40,15 @@ public class MultiUserEditorUndoTest extends EditorUndoTestCase { @Override protected void tearDown() throws Exception { - Disposer.dispose(myDisposable); - super.tearDown(); + try { + Disposer.dispose(myDisposable); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } public void testUndoSimpleCommandWithMovedRanges() { diff --git a/java/java-tests/testSrc/com/intellij/projectView/AbstractProjectViewTest.kt b/java/java-tests/testSrc/com/intellij/projectView/AbstractProjectViewTest.kt index 373a6602dd1c..da2df6a45687 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/AbstractProjectViewTest.kt +++ b/java/java-tests/testSrc/com/intellij/projectView/AbstractProjectViewTest.kt @@ -1,14 +1,10 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.projectView import com.intellij.ide.projectView.ProjectView import com.intellij.ide.projectView.ProjectViewSettings -import com.intellij.ide.projectView.impl.AbstractProjectViewPane -import com.intellij.ide.projectView.impl.PackageViewPane -import com.intellij.ide.projectView.impl.ProjectViewFileNestingService +import com.intellij.ide.projectView.impl.* import com.intellij.ide.projectView.impl.ProjectViewFileNestingService.NestingRule -import com.intellij.ide.projectView.impl.ProjectViewImpl -import com.intellij.ide.projectView.impl.ProjectViewPane import com.intellij.ide.scopeView.ScopeViewPane import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.vfs.VirtualFile @@ -29,8 +25,15 @@ abstract class AbstractProjectViewTest : TestSourceBasedTestCase() { private var originalNestingRules: MutableList? = null override fun tearDown() { - originalNestingRules?.let { ProjectViewFileNestingService.getInstance().rules = it } - super.tearDown() + try { + originalNestingRules?.let { ProjectViewFileNestingService.getInstance().rules = it } + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } override fun getTestPath(): String? = null diff --git a/java/java-tests/testSrc/com/intellij/projectView/CustomScopePaneTest.kt b/java/java-tests/testSrc/com/intellij/projectView/CustomScopePaneTest.kt index 880726280a55..071af2d001d4 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/CustomScopePaneTest.kt +++ b/java/java-tests/testSrc/com/intellij/projectView/CustomScopePaneTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.projectView import com.intellij.ide.projectView.ProjectViewNode @@ -19,8 +19,15 @@ class CustomScopePaneTest : AbstractProjectViewTest() { override fun isIconRequired() = true override fun tearDown() { - NamedScopeManager.getInstance(project).removeAllSets() - super.tearDown() + try { + NamedScopeManager.getInstance(project).removeAllSets() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } private fun allowed(any: Any?): Boolean { diff --git a/java/java-tests/testSrc/com/intellij/util/indexing/IndexDiagnosticTest.kt b/java/java-tests/testSrc/com/intellij/util/indexing/IndexDiagnosticTest.kt index c1a0833833d2..0a4697511665 100644 --- a/java/java-tests/testSrc/com/intellij/util/indexing/IndexDiagnosticTest.kt +++ b/java/java-tests/testSrc/com/intellij/util/indexing/IndexDiagnosticTest.kt @@ -32,10 +32,16 @@ class IndexDiagnosticTest : JavaCodeInsightFixtureTestCase() { } override fun tearDown() { - @Suppress("LocalVariableName") val _previousLogDir = previousLogDir - super.tearDown() - IndexDiagnosticDumper.shouldDumpInUnitTestMode = false - SystemProperties.setProperty(PathManager.PROPERTY_LOG_PATH, _previousLogDir) + try { + IndexDiagnosticDumper.shouldDumpInUnitTestMode = false + SystemProperties.setProperty(PathManager.PROPERTY_LOG_PATH, previousLogDir) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } @TestFor(issues = ["IDEA-252012"]) diff --git a/java/testFramework/src/com/intellij/refactoring/suggested/BaseSuggestedRefactoringChangeCollectorTest.kt b/java/testFramework/src/com/intellij/refactoring/suggested/BaseSuggestedRefactoringChangeCollectorTest.kt index 902bf00ccaed..10cc61d24b10 100644 --- a/java/testFramework/src/com/intellij/refactoring/suggested/BaseSuggestedRefactoringChangeCollectorTest.kt +++ b/java/testFramework/src/com/intellij/refactoring/suggested/BaseSuggestedRefactoringChangeCollectorTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.refactoring.suggested import com.intellij.lang.Language @@ -27,8 +27,15 @@ abstract class BaseSuggestedRefactoringChangeCollectorTest, highlightPolicy: HighlightPolicy, ignorePolicy: IgnorePolicy): List { val settings = TextDiffSettingsHolder.TextDiffSettings() diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/autoimport/AutoImportTestCase.kt b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/autoimport/AutoImportTestCase.kt index 2742619ea5fa..8649b829bfe5 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/autoimport/AutoImportTestCase.kt +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/autoimport/AutoImportTestCase.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.externalSystem.autoimport import com.intellij.core.CoreBundle @@ -16,9 +16,6 @@ import com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectTrack import com.intellij.openapi.externalSystem.autoimport.MockProjectAware.RefreshCollisionPassType import com.intellij.openapi.externalSystem.importing.ProjectResolverPolicy import com.intellij.openapi.externalSystem.service.project.autoimport.ProjectAware -import com.intellij.platform.externalSystem.testFramework.ExternalSystemTestCase -import com.intellij.platform.externalSystem.testFramework.ExternalSystemTestUtil.TEST_EXTERNAL_SYSTEM_ID -import com.intellij.platform.externalSystem.testFramework.TestExternalSystemManager import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.progress.util.BackgroundTaskUtil import com.intellij.openapi.project.Project @@ -30,6 +27,9 @@ import com.intellij.openapi.util.use import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile +import com.intellij.platform.externalSystem.testFramework.ExternalSystemTestCase +import com.intellij.platform.externalSystem.testFramework.ExternalSystemTestUtil.TEST_EXTERNAL_SYSTEM_ID +import com.intellij.platform.externalSystem.testFramework.TestExternalSystemManager import com.intellij.testFramework.ExtensionTestUtil import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.replaceService @@ -336,8 +336,15 @@ abstract class AutoImportTestCase : ExternalSystemTestCase() { } override fun tearDown() { - Disposer.dispose(testDisposable) - super.tearDown() + try { + Disposer.dispose(testDisposable) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } protected fun simpleModificationTest(test: SimpleModificationTestBench.() -> Unit) { diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/autolink/AutoLinkTestCase.kt b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/autolink/AutoLinkTestCase.kt index 61848a7ce9f0..7513e7d1622d 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/autolink/AutoLinkTestCase.kt +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/autolink/AutoLinkTestCase.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.externalSystem.autolink import com.intellij.openapi.Disposable @@ -8,10 +8,10 @@ import com.intellij.openapi.externalSystem.importing.AbstractOpenProjectProvider import com.intellij.openapi.externalSystem.importing.ExternalSystemSetupProjectTestCase import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys import com.intellij.openapi.externalSystem.model.ProjectSystemId -import com.intellij.platform.externalSystem.testFramework.ExternalSystemTestCase import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer import com.intellij.openapi.vfs.VirtualFile +import com.intellij.platform.externalSystem.testFramework.ExternalSystemTestCase import com.intellij.projectImport.ProjectOpenProcessor import com.intellij.testFramework.PlatformTestUtil import com.intellij.util.io.systemIndependentPath @@ -29,8 +29,15 @@ abstract class AutoLinkTestCase : ExternalSystemTestCase() { } override fun tearDown() { - Disposer.dispose(testDisposable) - super.tearDown() + try { + Disposer.dispose(testDisposable) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } override fun getTestsTempDir() = "tmp${System.currentTimeMillis()}" diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorageTest.kt b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorageTest.kt index fd6deb294a7d..09c875fb638e 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorageTest.kt +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsDataStorageTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.externalSystem.service.project.manage import com.intellij.openapi.externalSystem.model.DataNode @@ -25,8 +25,15 @@ class ExternalProjectsDataStorageTest: UsefulTestCase() { } override fun tearDown() { - myFixture.tearDown() - super.tearDown() + try { + myFixture.tearDown() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } @Test diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/ui/ExternalSystemJdkComboBoxUtilTestCase.kt b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/ui/ExternalSystemJdkComboBoxUtilTestCase.kt index 1e5db31cefba..d49d91bfdebf 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/ui/ExternalSystemJdkComboBoxUtilTestCase.kt +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/ui/ExternalSystemJdkComboBoxUtilTestCase.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.externalSystem.service.ui import com.intellij.openapi.application.ApplicationManager @@ -30,12 +30,19 @@ abstract class ExternalSystemJdkComboBoxUtilTestCase : SdkComboBoxTestCase() { } override fun tearDown() { - invokeAndWaitIfNeeded { - runWriteAction { - JavaAwareProjectJdkTableImpl.removeInternalJdkInTests() + try { + invokeAndWaitIfNeeded { + runWriteAction { + JavaAwareProjectJdkTableImpl.removeInternalJdkInTests() + } } } - super.tearDown() + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } open fun SdkComboBox.setSelectedJdkReference(jdkReference: String?) { diff --git a/platform/platform-tests/testSrc/com/intellij/application/TransactionTest.kt b/platform/platform-tests/testSrc/com/intellij/application/TransactionTest.kt index f8bed5be9469..cfeceff280f1 100644 --- a/platform/platform-tests/testSrc/com/intellij/application/TransactionTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/application/TransactionTest.kt @@ -46,10 +46,17 @@ class TransactionTest : LightPlatformTestCase() { } override fun tearDown() { - PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue() - log.clear() - LaterInvocator.leaveAllModals() - super.tearDown() + try { + PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue() + log.clear() + LaterInvocator.leaveAllModals() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } @Test diff --git a/platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/CompositeValidationRulesStorageTest.kt b/platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/CompositeValidationRulesStorageTest.kt index ff034d2f84ba..cd09866b5745 100644 --- a/platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/CompositeValidationRulesStorageTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/CompositeValidationRulesStorageTest.kt @@ -1,18 +1,25 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.internal.statistics.metadata.storage import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator import com.intellij.internal.statistic.eventLog.validator.rules.beans.EventGroupRules -import com.intellij.internal.statistic.eventLog.validator.storage.ValidationRulesInMemoryStorage import com.intellij.internal.statistic.eventLog.validator.storage.GroupValidationTestRule +import com.intellij.internal.statistic.eventLog.validator.storage.ValidationRulesInMemoryStorage import com.intellij.internal.statistic.eventLog.validator.storage.ValidationTestRulesPersistedStorage import org.assertj.core.api.Assertions.assertThat internal class CompositeValidationRulesStorageTest : ValidationRulesBaseStorageTest() { override fun tearDown() { - super.tearDown() - ValidationRulesInMemoryStorage.eventsValidators.clear() + try { + ValidationRulesInMemoryStorage.eventsValidators.clear() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun testGetGroupRulesFromTest() { diff --git a/platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/ValidationRulesBaseStorageTest.kt b/platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/ValidationRulesBaseStorageTest.kt index 6820a2feeccc..dfe4a00d2e57 100644 --- a/platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/ValidationRulesBaseStorageTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/ValidationRulesBaseStorageTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.internal.statistics.metadata.storage import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator @@ -25,17 +25,23 @@ internal abstract class ValidationRulesBaseStorageTest : BasePlatformTestCase() } override fun tearDown() { - super.tearDown() - - ValidationTestRulesPersistedStorage.cleanupAll() - for (recorder in recordersToCleanUp) { - val file = EventLogTestMetadataPersistence(recorder).eventsTestSchemeFile - try { - FileUtil.delete(file.parent) - } - catch (e: IOException) { - LOG.error(e) + try { + ValidationTestRulesPersistedStorage.cleanupAll() + for (recorder in recordersToCleanUp) { + val file = EventLogTestMetadataPersistence(recorder).eventsTestSchemeFile + try { + FileUtil.delete(file.parent) + } + catch (e: IOException) { + LOG.error(e) + } } } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } } \ No newline at end of file diff --git a/platform/platform-tests/testSrc/com/intellij/observable/CompoundParallelOperationTraceTestCase.kt b/platform/platform-tests/testSrc/com/intellij/observable/CompoundParallelOperationTraceTestCase.kt index d97bf623a335..9789a54cd748 100644 --- a/platform/platform-tests/testSrc/com/intellij/observable/CompoundParallelOperationTraceTestCase.kt +++ b/platform/platform-tests/testSrc/com/intellij/observable/CompoundParallelOperationTraceTestCase.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.observable import com.intellij.openapi.Disposable @@ -17,8 +17,12 @@ abstract class CompoundParallelOperationTraceTestCase : TestCase() { } override fun tearDown() { - Disposer.dispose(testDisposable) - super.tearDown() + try { + Disposer.dispose(testDisposable) + } + finally { + super.tearDown() + } } protected fun generate(times: Int, action: (Int) -> R): Iterable { diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/BaseSMTRunnerTestCase.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/BaseSMTRunnerTestCase.java index 9c70f753d672..fe0d4c19dbec 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/BaseSMTRunnerTestCase.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/BaseSMTRunnerTestCase.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.execution.testframework.sm.runner; import com.intellij.execution.configurations.ModuleRunConfiguration; @@ -29,9 +29,16 @@ public abstract class BaseSMTRunnerTestCase extends LightPlatformTestCase { @Override protected void tearDown() throws Exception { - if (mySuite != null) Disposer.dispose(mySuite); - if (mySimpleTest != null) Disposer.dispose(mySimpleTest); - super.tearDown(); + try { + if (mySuite != null) Disposer.dispose(mySuite); + if (mySimpleTest != null) Disposer.dispose(mySimpleTest); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } protected SMTestProxy createTestProxy() { diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java index d4e3edaa5356..07fce989da20 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.execution.testframework.sm.runner; import com.intellij.execution.executors.DefaultRunExecutor; @@ -94,13 +94,18 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase @Override protected void tearDown() throws Exception { - Disposer.dispose(myEventsProcessor); - Disposer.dispose(myConsole); - - super.tearDown(); - - if (myTempFile != null) { - assertFalse(myTempFile.exists()); + try { + Disposer.dispose(myEventsProcessor); + Disposer.dispose(myConsole); + if (myTempFile != null) { + assertFalse(myTempFile.exists()); + } + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); } } diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/TestSuiteStackTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/TestSuiteStackTest.java index 4ce50f0d462c..369e5f31988c 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/TestSuiteStackTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/TestSuiteStackTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.execution.testframework.sm.runner; import com.intellij.openapi.diagnostic.DefaultLogger; @@ -32,9 +18,15 @@ public class TestSuiteStackTest extends BaseSMTRunnerTestCase { @Override protected void tearDown() throws Exception { - disableDebugMode(); - - super.tearDown(); + try { + disableDebugMode(); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } public void testPushSuite() { diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerFiltersTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerFiltersTest.java index ba7e35879683..2b65a58874b3 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerFiltersTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerFiltersTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.execution.testframework.sm.runner.ui; import com.intellij.execution.testframework.TestConsoleProperties; @@ -22,8 +8,6 @@ import com.intellij.execution.testframework.sm.runner.SMTestProxy; import com.intellij.execution.ui.ConsoleView; import com.intellij.openapi.util.Disposer; -import javax.swing.*; - public class SMTRunnerFiltersTest extends BaseSMTRunnerTestCase { private MockTestResultsViewer myResultsViewer; private TestConsoleProperties myProperties; @@ -72,13 +56,20 @@ public class SMTRunnerFiltersTest extends BaseSMTRunnerTestCase { @Override protected void tearDown() throws Exception { - TestConsoleProperties.HIDE_PASSED_TESTS.set(myProperties, true); - TestConsoleProperties.HIDE_IGNORED_TEST.set(myProperties, false); - TestConsoleProperties.HIDE_SUCCESSFUL_CONFIG.set(myProperties, false); + try { + TestConsoleProperties.HIDE_PASSED_TESTS.set(myProperties, true); + TestConsoleProperties.HIDE_IGNORED_TEST.set(myProperties, false); + TestConsoleProperties.HIDE_SUCCESSFUL_CONFIG.set(myProperties, false); - Disposer.dispose(myResultsViewer); - Disposer.dispose(myResultsForm); - super.tearDown(); + Disposer.dispose(myResultsViewer); + Disposer.dispose(myResultsForm); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } public void testShowPassedShowIgnored() { diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java index 3998a7befdbf..446243552193 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.execution.testframework.sm.runner.ui; import com.intellij.execution.testframework.AbstractTestProxy; @@ -69,9 +55,16 @@ public class SMTRunnerUIActionsHandlerTest extends BaseSMTRunnerTestCase { @Override protected void tearDown() throws Exception { - Disposer.dispose(myResultsViewer); - Disposer.dispose(myResultsForm); - super.tearDown(); + try { + Disposer.dispose(myResultsViewer); + Disposer.dispose(myResultsForm); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } public void testSelectFirstDeffect_Failed() { diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java index 09f53632db51..0c6280b036a8 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.execution.testframework.sm.runner.ui; import com.intellij.execution.runners.ExecutionEnvironment; @@ -70,10 +56,16 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase { @Override protected void tearDown() throws Exception { - Disposer.dispose(myEventsProcessor); - Disposer.dispose(myConsole); - - super.tearDown(); + try { + Disposer.dispose(myEventsProcessor); + Disposer.dispose(myConsole); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } public void testGetTestsRootNode() { diff --git a/platform/testFramework/src/com/intellij/FileSetTestCase.java b/platform/testFramework/src/com/intellij/FileSetTestCase.java index a4d6f7e0a227..dfd759a10041 100644 --- a/platform/testFramework/src/com/intellij/FileSetTestCase.java +++ b/platform/testFramework/src/com/intellij/FileSetTestCase.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij; @@ -109,8 +109,15 @@ public abstract class FileSetTestCase extends TestSuite { @Override protected void tearDown() throws Exception { - FileSetTestCase.this.tearDown(); - super.tearDown(); + try { + FileSetTestCase.this.tearDown(); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } @Override diff --git a/platform/testFramework/src/com/intellij/testFramework/FlyIdeaTestCase.java b/platform/testFramework/src/com/intellij/testFramework/FlyIdeaTestCase.java index 70e381d32518..5cebfd4e7cf6 100644 --- a/platform/testFramework/src/com/intellij/testFramework/FlyIdeaTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/FlyIdeaTestCase.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.testFramework; import com.intellij.openapi.Disposable; @@ -32,10 +32,14 @@ public abstract class FlyIdeaTestCase extends TestCase { @Override protected void tearDown() throws Exception { - super.tearDown(); - if (myTempDir != null) { - FileUtil.asyncDelete(myTempDir); + try { + if (myTempDir != null) { + FileUtil.asyncDelete(myTempDir); + } + Disposer.dispose(myRootDisposable); + } + finally { + super.tearDown(); } - Disposer.dispose(myRootDisposable); } } diff --git a/plugins/editorconfig/test/org/editorconfig/configmanagement/EditorConfigEncodingInspectionTest.java b/plugins/editorconfig/test/org/editorconfig/configmanagement/EditorConfigEncodingInspectionTest.java index c94558354086..14bf683ac118 100644 --- a/plugins/editorconfig/test/org/editorconfig/configmanagement/EditorConfigEncodingInspectionTest.java +++ b/plugins/editorconfig/test/org/editorconfig/configmanagement/EditorConfigEncodingInspectionTest.java @@ -22,8 +22,15 @@ public class EditorConfigEncodingInspectionTest extends InspectionFixtureTestCas @Override protected void tearDown() throws Exception { - EditorConfigRegistry.setSkipProjectRootInTest(false); - super.tearDown(); + try { + EditorConfigRegistry.setSkipProjectRootInTest(false); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } public void testEncodingMismatch() { diff --git a/plugins/git4idea/tests/git4idea/commands/GitHttpGuiAuthenticatorTest.kt b/plugins/git4idea/tests/git4idea/commands/GitHttpGuiAuthenticatorTest.kt index 7b6d68c4a1ee..0a8774ef2294 100644 --- a/plugins/git4idea/tests/git4idea/commands/GitHttpGuiAuthenticatorTest.kt +++ b/plugins/git4idea/tests/git4idea/commands/GitHttpGuiAuthenticatorTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.commands import com.intellij.credentialStore.Credentials @@ -22,8 +22,7 @@ class GitHttpGuiAuthenticatorTest : GitPlatformTest() { private var dialogShown = false - @Throws(Exception::class) - public override fun setUp() { + override fun setUp() { super.setUp() // otherwise login dialog doesn't work (missing LaF for JBOptionButton) UIManager.setLookAndFeel("com.intellij.ide.ui.laf.darcula.DarculaLaf") @@ -32,14 +31,18 @@ class GitHttpGuiAuthenticatorTest : GitPlatformTest() { passwordSafe = service() } - @Throws(Exception::class) - public override fun tearDown() { - dialogShown = false - - rememberedInputs.clear() - passwordSafe.set(CREDENTIAL_ATTRIBUTES, null) - - super.tearDown() + override fun tearDown() { + try { + dialogShown = false + rememberedInputs.clear() + passwordSafe.set(CREDENTIAL_ATTRIBUTES, null) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun `test data saved when correct`() { diff --git a/plugins/git4idea/tests/git4idea/index/GitIndexStatusTest.kt b/plugins/git4idea/tests/git4idea/index/GitIndexStatusTest.kt index 26f0d0a1ef63..b8bfd5ebbce6 100644 --- a/plugins/git4idea/tests/git4idea/index/GitIndexStatusTest.kt +++ b/plugins/git4idea/tests/git4idea/index/GitIndexStatusTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.index import com.intellij.openapi.util.io.FileUtil @@ -94,9 +94,16 @@ class GitIndexStatusTest : GitPlatformTest() { } override fun tearDown() { - repositoryFiles.clear() - _repository = null - super.tearDown() + try { + repositoryFiles.clear() + _repository = null + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } private fun modify(file: FilePath) { diff --git a/plugins/git4idea/tests/git4idea/index/GitStageTrackerTest.kt b/plugins/git4idea/tests/git4idea/index/GitStageTrackerTest.kt index 01440fb0ad2c..89ecc2a859cd 100644 --- a/plugins/git4idea/tests/git4idea/index/GitStageTrackerTest.kt +++ b/plugins/git4idea/tests/git4idea/index/GitStageTrackerTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.index import com.google.common.util.concurrent.MoreExecutors @@ -43,11 +43,18 @@ class GitStageTrackerTest : GitSingleRepoTest() { } override fun tearDown() { - val t = _tracker - _tracker = null - t?.let { Disposer.dispose(it) } - repo.untrackedFilesHolder.createWaiter().waitFor() - super.tearDown() + try { + val t = _tracker + _tracker = null + t?.let { Disposer.dispose(it) } + repo.untrackedFilesHolder.createWaiter().waitFor() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun `test unstaged`() { diff --git a/plugins/git4idea/tests/git4idea/log/GitLogIndexTest.kt b/plugins/git4idea/tests/git4idea/log/GitLogIndexTest.kt index 8ab61165123d..ff2f0a224179 100644 --- a/plugins/git4idea/tests/git4idea/log/GitLogIndexTest.kt +++ b/plugins/git4idea/tests/git4idea/log/GitLogIndexTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.log import com.intellij.openapi.Disposable @@ -39,8 +39,15 @@ class GitLogIndexTest : GitSingleRepoTest() { } override fun tearDown() { - Disposer.dispose(disposable) - super.tearDown() + try { + Disposer.dispose(disposable) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun `test indexed`() { diff --git a/plugins/gradle/java/testSources/importing/GradleSetupProjectTest.kt b/plugins/gradle/java/testSources/importing/GradleSetupProjectTest.kt index f343ecef961a..6200402f370c 100644 --- a/plugins/gradle/java/testSources/importing/GradleSetupProjectTest.kt +++ b/plugins/gradle/java/testSources/importing/GradleSetupProjectTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.plugins.gradle.importing import com.intellij.openapi.Disposable @@ -6,8 +6,8 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.externalSystem.action.AttachExternalProjectAction -import com.intellij.openapi.externalSystem.autoimport.AutoImportProjectTracker import com.intellij.openapi.externalSystem.autoimport.AutoImportProjectNotificationAware +import com.intellij.openapi.externalSystem.autoimport.AutoImportProjectTracker import com.intellij.openapi.externalSystem.importing.ExternalSystemSetupProjectTest import com.intellij.openapi.externalSystem.importing.ExternalSystemSetupProjectTestCase import com.intellij.openapi.externalSystem.model.ProjectSystemId @@ -44,9 +44,15 @@ class GradleSetupProjectTest : ExternalSystemSetupProjectTest, GradleImportingTe } override fun tearDown() { - Disposer.dispose(testDisposable) - - super.tearDown() + try { + Disposer.dispose(testDisposable) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } override fun getSystemId(): ProjectSystemId = SYSTEM_ID diff --git a/plugins/grazie/src/test/kotlin/com/intellij/grazie/GrazieTestBase.kt b/plugins/grazie/src/test/kotlin/com/intellij/grazie/GrazieTestBase.kt index a442a48c44a7..04edef5f0601 100644 --- a/plugins/grazie/src/test/kotlin/com/intellij/grazie/GrazieTestBase.kt +++ b/plugins/grazie/src/test/kotlin/com/intellij/grazie/GrazieTestBase.kt @@ -55,8 +55,15 @@ abstract class GrazieTestBase : BasePlatformTestCase() { } override fun tearDown() { - GrazieConfig.update { GrazieConfig.State() } - super.tearDown() + try { + GrazieConfig.update { GrazieConfig.State() } + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } protected open fun runHighlightTestForFile(file: String) { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/codeInsight/hint/GroovyParameterTypeHintsInlayProviderTest.kt b/plugins/groovy/test/org/jetbrains/plugins/groovy/codeInsight/hint/GroovyParameterTypeHintsInlayProviderTest.kt index 93388d02bdcf..12943a448f59 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/codeInsight/hint/GroovyParameterTypeHintsInlayProviderTest.kt +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/codeInsight/hint/GroovyParameterTypeHintsInlayProviderTest.kt @@ -26,8 +26,15 @@ class GroovyParameterTypeHintsInlayProviderTest : InlayHintsProviderTestCase() { } override fun tearDown() { - Registry.get(MethodParameterAugmenter.GROOVY_COLLECT_METHOD_CALLS_FOR_INFERENCE).resetToDefault() - super.tearDown() + try { + Registry.get(MethodParameterAugmenter.GROOVY_COLLECT_METHOD_CALLS_FOR_INFERENCE).resetToDefault() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun testSingleType() { diff --git a/plugins/ide-features-trainer/testSrc/training/featuresSuggester/FeatureSuggesterTest.kt b/plugins/ide-features-trainer/testSrc/training/featuresSuggester/FeatureSuggesterTest.kt index 58cfbe58c949..9bb079cdf3fb 100644 --- a/plugins/ide-features-trainer/testSrc/training/featuresSuggester/FeatureSuggesterTest.kt +++ b/plugins/ide-features-trainer/testSrc/training/featuresSuggester/FeatureSuggesterTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package training.featuresSuggester import com.intellij.openapi.Disposable @@ -27,8 +27,15 @@ abstract class FeatureSuggesterTest : BasePlatformTestCase() { } override fun tearDown() { - Disposer.dispose(disposable) - super.tearDown() + try { + Disposer.dispose(disposable) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun assertSuggestedCorrectly() { diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInsight/folding/impl/PropertiesContextFoldingTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInsight/folding/impl/PropertiesContextFoldingTest.java index 6b6b7cc66685..4aa88fffb504 100644 --- a/plugins/java-i18n/testSrc/com/intellij/codeInsight/folding/impl/PropertiesContextFoldingTest.java +++ b/plugins/java-i18n/testSrc/com/intellij/codeInsight/folding/impl/PropertiesContextFoldingTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.folding.impl; import com.intellij.codeInsight.folding.JavaCodeFoldingSettings; @@ -31,8 +31,15 @@ public class PropertiesContextFoldingTest extends BasePlatformTestCase { @Override protected void tearDown() throws Exception { - PropertiesFoldingSettings.getInstance().setFoldPlaceholdersToContext(old); - super.tearDown(); + try { + PropertiesFoldingSettings.getInstance().setFoldPlaceholdersToContext(old); + } + catch (Throwable e) { + addSuppressedException(e); + } + finally { + super.tearDown(); + } } public void testPlaceholdersInPropertiesAreFolded() throws IOException { diff --git a/plugins/kotlin/base/plugin/test/org/jetbrains/kotlin/idea/artifacts/LazyFileOutputProducerTest.kt b/plugins/kotlin/base/plugin/test/org/jetbrains/kotlin/idea/artifacts/LazyFileOutputProducerTest.kt index 80e71f9b3d99..d52830b60202 100644 --- a/plugins/kotlin/base/plugin/test/org/jetbrains/kotlin/idea/artifacts/LazyFileOutputProducerTest.kt +++ b/plugins/kotlin/base/plugin/test/org/jetbrains/kotlin/idea/artifacts/LazyFileOutputProducerTest.kt @@ -21,9 +21,12 @@ class LazyFileOutputProducerTest : TestCase() { } override fun tearDown() { - super.tearDown() - tempDir.deleteRecursively() - AbstractLazyFileOutputProducer.invalidateCaches() + try { + tempDir.deleteRecursively() + AbstractLazyFileOutputProducer.invalidateCaches() + } finally { + super.tearDown() + } } fun `test simple upToDate`() { diff --git a/plugins/kotlin/compiler-plugins/kotlinx-serialization/tests/test/org/jetbrains/kotlin/idea/compilerPlugin/kotlinxSerialization/AbstractSerializationQuickFixTest.kt b/plugins/kotlin/compiler-plugins/kotlinx-serialization/tests/test/org/jetbrains/kotlin/idea/compilerPlugin/kotlinxSerialization/AbstractSerializationQuickFixTest.kt index f09290117fc5..aa1fc2b15c3a 100644 --- a/plugins/kotlin/compiler-plugins/kotlinx-serialization/tests/test/org/jetbrains/kotlin/idea/compilerPlugin/kotlinxSerialization/AbstractSerializationQuickFixTest.kt +++ b/plugins/kotlin/compiler-plugins/kotlinx-serialization/tests/test/org/jetbrains/kotlin/idea/compilerPlugin/kotlinxSerialization/AbstractSerializationQuickFixTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.compilerPlugin.kotlinxSerialization @@ -21,9 +21,13 @@ abstract class AbstractSerializationQuickFixTest : AbstractQuickFixTest() { } override fun tearDown() { - ConfigLibraryUtil.removeLibrary(module, "Serialization JSON") - ConfigLibraryUtil.removeLibrary(module, "Serialization core") - - super.tearDown() + try { + ConfigLibraryUtil.removeLibrary(module, "Serialization JSON") + ConfigLibraryUtil.removeLibrary(module, "Serialization core") + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() + } } } diff --git a/plugins/kotlin/compiler-plugins/parcelize/tests/test/org/jetbrains/kotlin/pacelize/ide/test/AbstractParcelizeCheckerTest.kt b/plugins/kotlin/compiler-plugins/parcelize/tests/test/org/jetbrains/kotlin/pacelize/ide/test/AbstractParcelizeCheckerTest.kt index bb501122bc1f..55dcd1804960 100644 --- a/plugins/kotlin/compiler-plugins/parcelize/tests/test/org/jetbrains/kotlin/pacelize/ide/test/AbstractParcelizeCheckerTest.kt +++ b/plugins/kotlin/compiler-plugins/parcelize/tests/test/org/jetbrains/kotlin/pacelize/ide/test/AbstractParcelizeCheckerTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.pacelize.ide.test @@ -11,7 +11,12 @@ abstract class AbstractParcelizeCheckerTest : AbstractKotlinHighlightVisitorTest } override fun tearDown() { - removeParcelizeLibraries(module) - super.tearDown() + try { + removeParcelizeLibraries(module) + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() + } } } \ No newline at end of file diff --git a/plugins/kotlin/compiler-plugins/parcelize/tests/test/org/jetbrains/kotlin/pacelize/ide/test/AbstractParcelizeQuickFixTest.kt b/plugins/kotlin/compiler-plugins/parcelize/tests/test/org/jetbrains/kotlin/pacelize/ide/test/AbstractParcelizeQuickFixTest.kt index bea68bd23d4e..6b6250da1257 100644 --- a/plugins/kotlin/compiler-plugins/parcelize/tests/test/org/jetbrains/kotlin/pacelize/ide/test/AbstractParcelizeQuickFixTest.kt +++ b/plugins/kotlin/compiler-plugins/parcelize/tests/test/org/jetbrains/kotlin/pacelize/ide/test/AbstractParcelizeQuickFixTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.pacelize.ide.test @@ -11,7 +11,12 @@ abstract class AbstractParcelizeQuickFixTest : AbstractQuickFixTest() { } override fun tearDown() { - removeParcelizeLibraries(module) - super.tearDown() + try { + removeParcelizeLibraries(module) + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() + } } } \ No newline at end of file diff --git a/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/gradle/ResolveModulesPerSourceSetInMppBuildIssueTest.kt b/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/gradle/ResolveModulesPerSourceSetInMppBuildIssueTest.kt index a32e44866419..1ed14ae653e1 100644 --- a/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/gradle/ResolveModulesPerSourceSetInMppBuildIssueTest.kt +++ b/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/gradle/ResolveModulesPerSourceSetInMppBuildIssueTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.gradle import com.intellij.openapi.actionSystem.DataContext @@ -12,14 +12,18 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.atomic.AtomicInteger class ResolveModulesPerSourceSetInMppBuildIssueTest : LightPlatformTestCase() { - override fun tearDown() { - GradleSettings.getInstance(project).apply { - linkedProjectsSettings.forEach { projectSetting -> - unlinkExternalProject(projectSetting.externalProjectPath) + try { + GradleSettings.getInstance(project).apply { + linkedProjectsSettings.forEach { projectSetting -> + unlinkExternalProject(projectSetting.externalProjectPath) + } } + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() } - super.tearDown() } diff --git a/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/idea/codeInsight/gradle/KotlinGradleImportingTestCase.kt b/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/idea/codeInsight/gradle/KotlinGradleImportingTestCase.kt index a435992d3bd0..b5dcfcd1aa04 100644 --- a/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/idea/codeInsight/gradle/KotlinGradleImportingTestCase.kt +++ b/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/idea/codeInsight/gradle/KotlinGradleImportingTestCase.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.codeInsight.gradle import com.intellij.execution.executors.DefaultRunExecutor @@ -73,8 +73,13 @@ abstract class KotlinGradleImportingTestCase : GradleImportingTestCase() { } override fun tearDown() { - tearDownImportStatusCollector() - super.tearDown() + try { + tearDownImportStatusCollector() + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() + } } protected open fun setUpImportStatusCollector() { diff --git a/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/notifications/LegacyIsResolveModulePerSourceSetNotificationTest.kt b/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/notifications/LegacyIsResolveModulePerSourceSetNotificationTest.kt index b3d34461c7a7..0a7d824f1d10 100644 --- a/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/notifications/LegacyIsResolveModulePerSourceSetNotificationTest.kt +++ b/plugins/kotlin/gradle/gradle-java/tests/test/org/jetbrains/kotlin/notifications/LegacyIsResolveModulePerSourceSetNotificationTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.notifications import com.intellij.notification.Notification @@ -40,13 +40,18 @@ class LegacyIsResolveModulePerSourceSetNotificationTest : LightPlatformTestCase( } override fun tearDown() { - GradleSettings.getInstance(project).apply { - linkedProjectsSettings.forEach { projectSetting -> - unlinkExternalProject(projectSetting.externalProjectPath) + try { + GradleSettings.getInstance(project).apply { + linkedProjectsSettings.forEach { projectSetting -> + unlinkExternalProject(projectSetting.externalProjectPath) + } } + notifications.forEach { it.expire() } + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() } - notifications.forEach { it.expire() } - super.tearDown() } fun `test shows notification when isResolveModulePerSourceSet is false`() { diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureTest.kt index f97a33af22b6..988a122cfec5 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.refactoring.changeSignature @@ -42,8 +42,6 @@ import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.idea.test.InTextDirectivesUtils -import org.jetbrains.kotlin.idea.test.KotlinTestUtils import org.jetbrains.kotlin.types.typeUtil.makeNullable import org.jetbrains.kotlin.utils.addToStdlib.assertedCast import org.jetbrains.kotlin.utils.addToStdlib.safeAs @@ -71,9 +69,14 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() { } override fun tearDown() { - files = emptyList() - psiFiles = PsiFile.EMPTY_ARRAY - super.tearDown() + try { + files = emptyList() + psiFiles = PsiFile.EMPTY_ARRAY + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() + } } private lateinit var files: List diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/run/KotlinJUnitLightTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/run/KotlinJUnitLightTest.kt index ecb583abbadb..6ecae0c745fd 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/run/KotlinJUnitLightTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/run/KotlinJUnitLightTest.kt @@ -34,11 +34,16 @@ class KotlinJUnitLightTest : LightJavaCodeInsightFixtureTestCase() { @Throws(Exception::class) override fun tearDown() { - val runManager = getInstance(project) - for (setting in tempSettings) { - runManager.removeConfiguration(setting) + try { + val runManager = getInstance(project) + for (setting in tempSettings) { + runManager.removeConfiguration(setting) + } + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() } - super.tearDown() } override fun setUp() { diff --git a/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/AbstractKotlinEvaluateExpressionTest.kt b/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/AbstractKotlinEvaluateExpressionTest.kt index b5fc4f6fd7ae..ae23cffb9acb 100644 --- a/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/AbstractKotlinEvaluateExpressionTest.kt +++ b/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/AbstractKotlinEvaluateExpressionTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.debugger.test @@ -91,8 +91,13 @@ abstract class AbstractKotlinEvaluateExpressionTest : KotlinDescriptorTestCaseWi } override fun tearDown() { - exceptions.clear() - super.tearDown() + try { + exceptions.clear() + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() + } } private fun performSingleBreakpointTest(data: EvaluationTestData) { diff --git a/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinDescriptorTestCaseWithStepping.kt b/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinDescriptorTestCaseWithStepping.kt index 0b51268802c2..3dd488eb924a 100644 --- a/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinDescriptorTestCaseWithStepping.kt +++ b/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinDescriptorTestCaseWithStepping.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.debugger.test @@ -144,8 +144,13 @@ abstract class KotlinDescriptorTestCaseWithStepping : KotlinDescriptorTestCase() } override fun tearDown() { - super.tearDown() - classPath.clear() + try { + classPath.clear() + } catch (e: Throwable) { + addSuppressedException(e) + } finally { + super.tearDown() + } } private fun SuspendContextImpl.doStepOver(ignoreBreakpoints: Boolean = false) { diff --git a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/codegen/CodegenTestCase.java b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/codegen/CodegenTestCase.java index 7695ad82e582..89dba21add8d 100644 --- a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/codegen/CodegenTestCase.java +++ b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/codegen/CodegenTestCase.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.codegen; @@ -9,26 +9,19 @@ import kotlin.io.FilesKt; import kotlin.text.Charsets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.codegen.ClassFileFactory; -import org.jetbrains.kotlin.codegen.GeneratedClassLoader; -import org.jetbrains.kotlin.idea.TestHelperGeneratorKt; import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; -import org.jetbrains.kotlin.idea.test.InTextDirectivesUtils; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; +import org.jetbrains.kotlin.codegen.ClassFileFactory; +import org.jetbrains.kotlin.codegen.GeneratedClassLoader; import org.jetbrains.kotlin.config.CompilerConfiguration; -import org.jetbrains.kotlin.idea.test.Directives; +import org.jetbrains.kotlin.idea.TestHelperGeneratorKt; import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts; -import org.jetbrains.kotlin.idea.test.ConfigurationKind; -import org.jetbrains.kotlin.idea.test.KotlinTestUtils; +import org.jetbrains.kotlin.idea.test.*; +import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.test.TargetBackend; import org.jetbrains.kotlin.test.TestJdkKind; -import org.jetbrains.kotlin.psi.KtFile; -import org.jetbrains.kotlin.test.*; -import org.jetbrains.kotlin.idea.test.TestFiles; import org.jetbrains.kotlin.utils.ExceptionUtilsKt; -import org.jetbrains.kotlin.idea.test.KotlinBaseTest; -import org.jetbrains.kotlin.idea.test.KotlinBaseTest.TestFile; import java.io.File; import java.io.IOException; @@ -66,16 +59,20 @@ public abstract class CodegenTestCase extends KotlinBaseTest files) { diff --git a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/test/testFramework/KtPlatformLiteFixture.java b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/test/testFramework/KtPlatformLiteFixture.java index ef033b3d2217..d236b3569ecc 100644 --- a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/test/testFramework/KtPlatformLiteFixture.java +++ b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/test/testFramework/KtPlatformLiteFixture.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.test.testFramework; @@ -24,9 +24,14 @@ public abstract class KtPlatformLiteFixture extends KtUsefulTestCase { @Override protected void tearDown() throws Exception { - super.tearDown(); - clearFields(this); - myProject = null; + try { + clearFields(this); + myProject = null; + } catch (Throwable e) { + addSuppressedException(e); + } finally { + super.tearDown(); + } } @SuppressWarnings("unchecked") diff --git a/plugins/markdown/test/src/org/intellij/plugins/markdown/editor/tables/MarkdownTableTabTest.kt b/plugins/markdown/test/src/org/intellij/plugins/markdown/editor/tables/MarkdownTableTabTest.kt index daf7689d75bc..a9c7cd9c6b62 100644 --- a/plugins/markdown/test/src/org/intellij/plugins/markdown/editor/tables/MarkdownTableTabTest.kt +++ b/plugins/markdown/test/src/org/intellij/plugins/markdown/editor/tables/MarkdownTableTabTest.kt @@ -7,8 +7,15 @@ import org.intellij.plugins.markdown.editor.tables.TableTestUtils.runWithChanged class MarkdownTableTabTest: LightPlatformCodeInsightTestCase() { override fun tearDown() { - TestScaleHelper.restoreRegistryProperties() - super.tearDown() + try { + TestScaleHelper.restoreRegistryProperties() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun `test single tab forward`() { diff --git a/plugins/markdown/test/src/org/intellij/plugins/markdown/formatter/MarkdownFormatterTest.kt b/plugins/markdown/test/src/org/intellij/plugins/markdown/formatter/MarkdownFormatterTest.kt index f37a2edf3eb7..8804ab9776fb 100644 --- a/plugins/markdown/test/src/org/intellij/plugins/markdown/formatter/MarkdownFormatterTest.kt +++ b/plugins/markdown/test/src/org/intellij/plugins/markdown/formatter/MarkdownFormatterTest.kt @@ -38,16 +38,21 @@ open class MarkdownFormatterTest : LightPlatformCodeInsightTestCase() { } override fun tearDown() { - val settings = CodeStyle.getSettings(project) - val common = settings.getCommonSettings(MarkdownLanguage.INSTANCE) - val custom = settings.getCustomSettings(MarkdownCustomCodeStyleSettings::class.java) - - settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myOldWrap - common.RIGHT_MARGIN = myOldMargin - custom.WRAP_TEXT_IF_LONG = myOldWrapTextBlocksIfLong - custom.KEEP_LINE_BREAKS_INSIDE_TEXT_BLOCKS = myOldKeepLineBreaks - - super.tearDown() + try { + val settings = CodeStyle.getSettings(project) + val common = settings.getCommonSettings(MarkdownLanguage.INSTANCE) + val custom = settings.getCustomSettings(MarkdownCustomCodeStyleSettings::class.java) + settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myOldWrap + common.RIGHT_MARGIN = myOldMargin + custom.WRAP_TEXT_IF_LONG = myOldWrapTextBlocksIfLong + custom.KEEP_LINE_BREAKS_INSIDE_TEXT_BLOCKS = myOldKeepLineBreaks + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } fun testSmoke() { diff --git a/plugins/search-everywhere-ml/test/com/intellij/ide/actions/searcheverywhere/ml/SearchEverywhereBaseFileFeaturesProviderTest.kt b/plugins/search-everywhere-ml/test/com/intellij/ide/actions/searcheverywhere/ml/SearchEverywhereBaseFileFeaturesProviderTest.kt index 667ff51c192a..8ff2e6144650 100644 --- a/plugins/search-everywhere-ml/test/com/intellij/ide/actions/searcheverywhere/ml/SearchEverywhereBaseFileFeaturesProviderTest.kt +++ b/plugins/search-everywhere-ml/test/com/intellij/ide/actions/searcheverywhere/ml/SearchEverywhereBaseFileFeaturesProviderTest.kt @@ -57,8 +57,15 @@ internal abstract class SearchEverywhereBaseFileFeaturesProviderTest { - dir.findChild(testsFolderName)?.let { VfsTestUtil.deleteFile(it) } + try { + ApplicationManager.getApplication().invokeAndWait { + WriteAction.runAndWait { + dir.findChild(testsFolderName)?.let { VfsTestUtil.deleteFile(it) } + } } } - super.tearDown() + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } private fun getModelForFunc() = getModel(null) diff --git a/python/testSrc/com/jetbrains/python/console/PyConsoleEnterHandlerTest.kt b/python/testSrc/com/jetbrains/python/console/PyConsoleEnterHandlerTest.kt index b149500e58a5..3462beb6d33c 100644 --- a/python/testSrc/com/jetbrains/python/console/PyConsoleEnterHandlerTest.kt +++ b/python/testSrc/com/jetbrains/python/console/PyConsoleEnterHandlerTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.python.console import com.intellij.openapi.command.WriteCommandAction @@ -170,8 +170,14 @@ class PyConsoleEnterHandlerTest : PyTestCase() { } override fun tearDown() { - Disposer.dispose(testRootDisposable) - super.tearDown() + try { + Disposer.dispose(testRootDisposable) + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } - } diff --git a/python/testSrc/com/jetbrains/python/inspections/PyRelativeImportInspectionTest.kt b/python/testSrc/com/jetbrains/python/inspections/PyRelativeImportInspectionTest.kt index ce8d07b4cc21..74e329e05512 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyRelativeImportInspectionTest.kt +++ b/python/testSrc/com/jetbrains/python/inspections/PyRelativeImportInspectionTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.python.inspections import com.intellij.application.options.RegistryManager @@ -15,8 +15,15 @@ class PyRelativeImportInspectionTest: PyInspectionTestCase() { } override fun tearDown() { - RegistryManager.getInstance()["python.explicit.namespace.packages"].resetToDefault() - super.tearDown() + try { + RegistryManager.getInstance()["python.explicit.namespace.packages"].resetToDefault() + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } } override fun getInspectionClass(): Class {