let _LastInSuiteTest find project leaks from app-level extensions (e.g. completion contributors)

This commit is contained in:
peter
2017-05-26 17:44:47 +02:00
parent 2733cf53b0
commit daff4bd0a7
2 changed files with 21 additions and 13 deletions
@@ -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);
}
@@ -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);
}