diff options
author | Jens Baumgart | 2010-09-08 14:42:36 +0000 |
---|---|---|
committer | Matthias Sohn | 2010-09-08 14:42:36 +0000 |
commit | ff2c89b7635c17e55ddfc1d37fc91b60ff405a1e (patch) | |
tree | f0f492b745dc0a9a6c07fcf3efc1058c46fc33b3 | |
parent | fd50173b0086785c5e7338c2962310e5f5a3e918 (diff) | |
download | egit-ff2c89b7635c17e55ddfc1d37fc91b60ff405a1e.tar.gz egit-ff2c89b7635c17e55ddfc1d37fc91b60ff405a1e.tar.xz egit-ff2c89b7635c17e55ddfc1d37fc91b60ff405a1e.zip |
Clear RepositoryCache after each test to fix core tests
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.java | 4 | ||||
-rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java | 8 |
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 a6ceca2a72..da5920dd9b 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 8d4311e0f5..4027ee95c9 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(); + } + } |