From aafd460e77ff69b778cadf1df5887bdf767b8332 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 20 Feb 2012 11:18:52 +0100 Subject: [PATCH] AppCode: 'fix' for Xcode3 tests --- .../testFramework/PlatformTestCase.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java index 7c92f6ebc3b8..4e4a6bb5553d 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java @@ -110,7 +110,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro private ThreadTracker myThreadTracker; protected static boolean ourPlatformPrefixInitialized; - private static Set ourEternallyLivingFiles; + private static Set ourEternallyLivingFilesCache; static { Logger.setFactory(TestLoggerFactory.getInstance()); @@ -343,20 +343,9 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro PatchedWeakReference.clearAll(); } - private static void addSubTree(VirtualFile root, Set to) { - if (root instanceof VirtualDirectoryImpl) { - for (VirtualFile child : ((VirtualDirectoryImpl)root).getCachedChildren()) { - if (child instanceof VirtualDirectoryImpl) { - to.add(child); - addSubTree(child, to); - } - } - } - } - - public static Set eternallyLivingFiles() { - if (ourEternallyLivingFiles != null) { - return ourEternallyLivingFiles; + private static Set eternallyLivingFiles() { + if (ourEternallyLivingFilesCache != null) { + return ourEternallyLivingFilesCache; } Set survivors = new HashSet(); @@ -367,17 +356,34 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro } } - ourEternallyLivingFiles = survivors; + ourEternallyLivingFilesCache = survivors; return survivors; } - public static void registerSurvivor(Set survivors, VirtualFile file) { + public static void addSurvivingFiles(@NotNull Collection files) { + for (VirtualFile each : files) { + registerSurvivor(eternallyLivingFiles(), each); + } + } + + private static void registerSurvivor(Set survivors, VirtualFile file) { addSubTree(file, survivors); while (file != null && survivors.add(file)) { file = file.getParent(); } } + private static void addSubTree(VirtualFile root, Set to) { + if (root instanceof VirtualDirectoryImpl) { + for (VirtualFile child : ((VirtualDirectoryImpl)root).getCachedChildren()) { + if (child instanceof VirtualDirectoryImpl) { + to.add(child); + addSubTree(child, to); + } + } + } + } + @Override protected void tearDown() throws Exception { CompositeException result = new CompositeException();