summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2010-08-20 10:15:53 +0200
committerChristian Halstrick <christian.halstrick@sap.com>2010-08-20 10:23:03 +0200
commit9ac29d0e912b999526184860d56611a9ad3f692d (patch)
tree546f994fcc308e764fe95fdfcc5f1d9749fe6743
parent3820b0281ab5abff0123d56e0886a4830ee3d424 (diff)
downloadjgit-9ac29d0e912b999526184860d56611a9ad3f692d.tar.gz
jgit-9ac29d0e912b999526184860d56611a9ad3f692d.zip
Fix ReadTreeTests to not rely on cached index
ReadTreeTests relied on Repository.getIndex() which on platforms which coarse FileSystemTimers failed to detect index modifications. By explicitly reloading and writing the index this problem is solved. Change-Id: I0a98babfc2068a3b6b7d2257834988e1154f5b26 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/WorkDirCheckout_ReadTreeTest.java4
2 files changed, 7 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java
index 2fa45c8211..fe2d0b248c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java
@@ -651,6 +651,10 @@ public abstract class ReadTreeTest extends RepositoryTestCase {
String expectedValue;
String path;
GitIndex theIndex=db.getIndex();
+ // Without an explicit refresh we might miss index updates. If the index
+ // is updated multiple times inside a FileSystemTimer tick db.getIndex will
+ // not reload the index and return a cached (stale) index.
+ theIndex.read();
assertEquals("Index has not the right size.", i.size(),
theIndex.getMembers().length);
for (int j = 0; j < theIndex.getMembers().length; j++) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/WorkDirCheckout_ReadTreeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/WorkDirCheckout_ReadTreeTest.java
index 7b5c3cdc57..c41a04cc90 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/WorkDirCheckout_ReadTreeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/WorkDirCheckout_ReadTreeTest.java
@@ -57,8 +57,10 @@ public class WorkDirCheckout_ReadTreeTest extends ReadTreeTest {
}
public void checkout() throws IOException {
- wdc = new WorkDirCheckout(db, db.getWorkTree(), theHead, db.getIndex(), theMerge);
+ GitIndex index = db.getIndex();
+ wdc = new WorkDirCheckout(db, db.getWorkTree(), theHead, index, theMerge);
wdc.checkout();
+ index.write();
}
public ArrayList<String> getRemoved() {