]> source.dussan.org Git - jgit.git/commitdiff
Fix ReadTreeTests to not rely on cached index 52/1352/1
authorChristian Halstrick <christian.halstrick@sap.com>
Fri, 20 Aug 2010 08:15:53 +0000 (10:15 +0200)
committerChristian Halstrick <christian.halstrick@sap.com>
Fri, 20 Aug 2010 08:23:03 +0000 (10:23 +0200)
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>
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/WorkDirCheckout_ReadTreeTest.java

index 2fa45c8211b73f08886d1b0a46dfc74aa9fe7f14..fe2d0b248c758407b4ceb6f2adb68c4e563c257c 100644 (file)
@@ -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++) {
index 7b5c3cdc57754afe1819cbb4c6af1c1887308e27..c41a04cc90fa703bd62dcd469e4f2c66c6d5fd42 100644 (file)
@@ -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() {