Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Rosenberg2014-06-28 13:31:11 +0000
committerMatthias Sohn2014-07-01 13:29:11 +0000
commit0f14d3bf408d11549f861f22556c4740f9c13207 (patch)
tree390a26846d2ec000af2b1f188e6c4640b40a739d /org.eclipse.jgit.junit
parent10aee9b1b70a857548adbd37592fb0c7ece024bb (diff)
downloadjgit-0f14d3bf408d11549f861f22556c4740f9c13207.tar.gz
jgit-0f14d3bf408d11549f861f22556c4740f9c13207.tar.xz
jgit-0f14d3bf408d11549f861f22556c4740f9c13207.zip
Try to fix intermittent test failure related to file timestamps
Improve how tests do a "touch" operation on files. Instead of doing "f.setLastModified(System.currentTimeMillis)" open a Outputstream on the file and directly close it again. This makes this method rely only on one clock - the clock of the filesystem. Bug: 436917 Change-Id: I68ef3c2878f28b12daebf2ef6a9fa0a5d6e0964d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
index 15334ee396..c1e0a2dcf3 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
@@ -375,7 +375,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
*/
public static long fsTick(File lastFile) throws InterruptedException,
IOException {
- long sleepTime = 1;
+ long sleepTime = 64;
FS fs = FS.DETECTED;
if (lastFile != null && !fs.exists(lastFile))
throw new FileNotFoundException(lastFile.getPath());
@@ -386,8 +386,9 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
long actTime = fs.lastModified(tmp);
while (actTime <= startTime) {
Thread.sleep(sleepTime);
- sleepTime *= 5;
- fs.setLastModified(tmp, System.currentTimeMillis());
+ sleepTime *= 2;
+ FileOutputStream fos = new FileOutputStream(tmp);
+ fos.close();
actTime = fs.lastModified(tmp);
}
return actTime;

Back to the top