aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2010-09-08 10:42:36 (EDT)
committerMatthias Sohn2010-09-08 10:42:36 (EDT)
commitff2c89b7635c17e55ddfc1d37fc91b60ff405a1e (patch)
treef0f492b745dc0a9a6c07fcf3efc1058c46fc33b3
parentfd50173b0086785c5e7338c2962310e5f5a3e918 (diff)
downloadegit-ff2c89b7635c17e55ddfc1d37fc91b60ff405a1e.zip
egit-ff2c89b7635c17e55ddfc1d37fc91b60ff405a1e.tar.gz
egit-ff2c89b7635c17e55ddfc1d37fc91b60ff405a1e.tar.bz2
Clear RepositoryCache after each test to fix core testsrefs/changes/64/1564/2
With this fix the core test suite is running also on Mac. Reason for the failures before was the usage of out-dated Repository instances contained in RepositoryCache which caused spurious failures when running the full test suite while running tests individually always succeeded. A follow-up fix should care for the life cycle of Repository objects in RepositoryCache. Change-Id: I1f16a9de48435bd98e2520e34e49bc1ca6893f14 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java4
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java8
2 files changed, 12 insertions, 0 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
index a6ceca2..da5920d 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
@@ -15,6 +15,7 @@ import java.io.IOException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.egit.core.Activator;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -35,6 +36,9 @@ public abstract class GitTestCase {
@Before
public void setUp() throws Exception {
+ // ensure there are no shared Repository instances left
+ // when starting a new test
+ Activator.getDefault().getRepositoryCache().clear();
MockSystemReader mockSystemReader = new MockSystemReader();
SystemReader.setInstance(mockSystemReader);
mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY,
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java
index 8d4311e..4027ee9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java
@@ -78,4 +78,12 @@ public class RepositoryCache {
}
}
+ /**
+ * TESTING ONLY!
+ * Unit tests can use this method to get a clean beginning state
+ */
+ public void clear() {
+ repositoryCache.clear();
+ }
+
}