From d4d71da8920052714dafdfda9c12a9c5a054a04f Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 29 Dec 2017 10:18:44 +0100 Subject: [PATCH] dispose fixture root disposable before project fixture tearDown the latter checks if temp injectors are removed, and they're removed in the former should fix damn flaky PsiAnchorTest (still not sure why flaky) --- .../testFramework/fixtures/impl/BaseFixture.java | 10 +++++++++- .../fixtures/impl/CodeInsightTestFixtureImpl.java | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/BaseFixture.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/BaseFixture.java index c0381fc09335..7b56807c3055 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/BaseFixture.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/BaseFixture.java @@ -47,11 +47,19 @@ public class BaseFixture implements IdeaTestFixture { public void tearDown() throws Exception { Assert.assertTrue("setUp() has not been called", myInitialized); Assert.assertFalse("tearDown() already has been called", myDisposed); - EdtTestUtil.runInEdtAndWait(() -> Disposer.dispose(myTestRootDisposable)); + disposeRootDisposable(); myDisposed = true; resetClassFields(getClass()); } + protected void disposeRootDisposable() { + EdtTestUtil.runInEdtAndWait(() -> { + if (!Disposer.isDisposed(myTestRootDisposable)) { + Disposer.dispose(myTestRootDisposable); + } + }); + } + private void resetClassFields(final Class aClass) { try { UsefulTestCase.clearDeclaredFields(this, aClass); diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 4d3e81b9ba5b..a724e12b61d9 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1237,6 +1237,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig myChooseByNamePopup = null; }) // don't use method references here to make stack trace reading easier + .append(() -> disposeRootDisposable()) .append(() -> EdtTestUtil.runInEdtAndWait(() -> myProjectFixture.tearDown())) .append(() -> EdtTestUtil.runInEdtAndWait(() -> myTempDirFixture.tearDown())) .append(() -> super.tearDown())