make sure that CompilerTester is disposed

This commit is contained in:
Vladimir Krivosheev
2018-08-21 08:03:59 +02:00
parent 81575abc91
commit f564bd4582
2 changed files with 14 additions and 10 deletions
@@ -489,15 +489,18 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
public static void checkEditorsReleased() {
// don't use method references here to make stack trace reading easier
//noinspection Convert2MethodRef
RunAll runAll = new RunAll(() -> UIUtil.dispatchAllInvocationEvents());
for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
runAll = runAll
.append(
() -> EditorFactoryImpl.throwNotReleasedError(editor),
() -> EditorFactory.getInstance().releaseEditor(editor)
);
}
runAll.run();
new RunAll(
() -> UIUtil.dispatchAllInvocationEvents(),
() -> {
// getAllEditors() should be called only after dispatchAllInvocationEvents(), that's why separate RunAll is used
RunAll runAll = new RunAll();
for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
runAll = runAll
.append(() -> EditorFactoryImpl.throwNotReleasedError(editor))
.append(() -> EditorFactory.getInstance().releaseEditor(editor));
}
runAll.run();
}).run();
}
@Override
@@ -9,6 +9,7 @@ import com.intellij.util.lang.CompoundRuntimeException;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
/**
@@ -31,7 +32,7 @@ public class RunAll implements Runnable {
@SafeVarargs
@Contract(pure=true)
public final RunAll append(@NotNull ThrowableRunnable<Throwable>... actions) {
return new RunAll(ContainerUtil.concat(myActions, ContainerUtilRt.newArrayList(actions)));
return new RunAll(ContainerUtil.concat(myActions, actions.length == 1 ? Collections.singletonList(actions[0]) : ContainerUtilRt.newArrayList(actions)));
}
@Override