ensure project leak hunter is started (when first test which init the app is UsefulTestCase, then initial val of ourDebugMode is false and it would be restored in tearDown, afterwards only explicit setting to true would help)

This commit is contained in:
Anna.Kozlova
2017-02-07 09:49:38 +01:00
parent b45cf8967a
commit af7dd1def7
5 changed files with 25 additions and 5 deletions
@@ -163,8 +163,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
AWTExceptionHandler.register(); // do not crash AWT on exceptions
String debugDisposer = System.getProperty("idea.disposer.debug");
Disposer.setDebugMode((isInternal || isUnitTestMode || "on".equals(debugDisposer)) && !"off".equals(debugDisposer));
Disposer.setDebugMode((isInternal || isUnitTestMode || Disposer.isDebugDisposerOn()));
myStartTime = System.currentTimeMillis();
mySplash = splash;
@@ -18,6 +18,7 @@ package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.configurations.ModuleRunConfiguration;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.openapi.util.Disposer;
import com.intellij.testFramework.LightPlatformTestCase;
/**
@@ -35,6 +36,13 @@ public abstract class BaseSMTRunnerTestCase extends LightPlatformTestCase {
mySimpleTest = createTestProxy();
}
@Override
protected void tearDown() throws Exception {
if (mySuite != null) Disposer.dispose(mySuite);
if (mySimpleTest != null) Disposer.dispose(mySimpleTest);
super.tearDown();
}
protected SMTestProxy createTestProxy() {
return createTestProxy("test");
}
@@ -42,6 +42,12 @@ import java.util.concurrent.TimeUnit;
*/
@SuppressWarnings("JUnitTestClassNamingConvention")
public class _LastInSuiteTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
Disposer.setDebugMode(true);
}
public void testProjectLeak() throws Exception {
boolean guiTestMode = Boolean.getBoolean("idea.test.guimode");
if (guiTestMode) {
@@ -147,7 +147,7 @@ public abstract class UsefulTestCase extends TestCase {
boolean isStressTest = isStressTest();
ApplicationInfoImpl.setInStressTest(isStressTest);
// turn off Disposer debugging for performance tests
oldDisposerDebug = Disposer.setDebugMode(Disposer.isDebugMode() && !isStressTest);
Disposer.setDebugMode(!isStressTest);
}
@Override
@@ -158,7 +158,6 @@ public abstract class UsefulTestCase extends TestCase {
cleanupDeleteOnExitHookList();
}
finally {
Disposer.setDebugMode(oldDisposerDebug);
if (shouldContainTempFiles()) {
FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR);
if (hasTmpFilesToKeep()) {
@@ -56,6 +56,11 @@ public class Disposer {
}
};
private static String debugDisposer = System.getProperty("idea.disposer.debug");
public static boolean isDebugDisposerOn() {
return "on".equals(debugDisposer);
}
private static boolean ourDebugMode;
private Disposer() {
@@ -144,7 +149,10 @@ public class Disposer {
/**
* @return old value
*/
public static boolean setDebugMode(final boolean debugMode) {
public static boolean setDebugMode(boolean debugMode) {
if (debugMode) {
debugMode = !"off".equals(debugDisposer);
}
boolean oldValue = ourDebugMode;
ourDebugMode = debugMode;
return oldValue;