mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
let _LastInSuiteTest find project leaks from app-level extensions (e.g. completion contributors)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user