diff --git a/platform/testFramework/src/_LastInSuiteTest.java b/platform/testFramework/src/_LastInSuiteTest.java index 187cd33347d9..b11fa3d2d501 100644 --- a/platform/testFramework/src/_LastInSuiteTest.java +++ b/platform/testFramework/src/_LastInSuiteTest.java @@ -26,6 +26,7 @@ import com.intellij.openapi.util.ShutDownTracker; import com.intellij.testFramework.LeakHunter; import com.intellij.testFramework.LightPlatformTestCase; import com.intellij.testFramework.PlatformTestUtil; +import com.intellij.util.ExceptionUtil; import com.intellij.util.ReflectionUtil; import com.intellij.util.concurrency.AppExecutorUtil; import com.intellij.util.concurrency.AppScheduledExecutorService; @@ -78,8 +79,8 @@ public class _LastInSuiteTest extends TestCase { throw new RuntimeException(e); } - // disposes default projects too PlatformTestUtil.cleanupAllProjects(); + ApplicationImpl application = (ApplicationImpl)ApplicationManager.getApplication(); System.out.println(application.writeActionStatistics()); System.out.println(ActionUtil.ActionPauses.STAT.statistics()); @@ -87,19 +88,21 @@ public class _LastInSuiteTest extends TestCase { System.out.println("ProcessIOExecutorService threads created: " + ((ProcessIOExecutorService)ProcessIOExecutorService.INSTANCE).getThreadCounter()); - application.setDisposeInProgress(true); - LightPlatformTestCase.disposeApplication(); - UIUtil.dispatchAllInvocationEvents(); + try { + LeakHunter.checkNonDefaultProjectLeak(); + } + catch (AssertionError | Exception e) { + captureMemorySnapshot(); + ExceptionUtil.rethrowAllAsUnchecked(e); + } + finally { + application.setDisposeInProgress(true); + LightPlatformTestCase.disposeApplication(); + UIUtil.dispatchAllInvocationEvents(); + } + }); - try { - LeakHunter.checkProjectLeak(); - Disposer.assertIsEmpty(true); - } - catch (AssertionError | Exception e) { - captureMemorySnapshot(); - throw e; - } try { Disposer.assertIsEmpty(true); } diff --git a/platform/testFramework/src/com/intellij/testFramework/LeakHunter.java b/platform/testFramework/src/com/intellij/testFramework/LeakHunter.java index 9423575873a3..dbbd9db7f399 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LeakHunter.java +++ b/platform/testFramework/src/com/intellij/testFramework/LeakHunter.java @@ -42,7 +42,12 @@ public class LeakHunter { } @TestOnly - public static void checkLeak(@NotNull Object root, @NotNull Class suspectClass) throws AssertionError { + public static void checkNonDefaultProjectLeak() throws Exception { + checkLeak(allRoots(), ProjectImpl.class, project -> !project.isDefault()); + } + + @TestOnly + public static void checkLeak(@NotNull Object root, @NotNull Class suspectClass) throws AssertionError { checkLeak(root, suspectClass, null); }