diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-06-06 11:34:56 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-06-06 17:14:31 +0200 |
commit | d9c569b74725b4ffe9fa085ff1542b619cbcf4ce (patch) | |
tree | 5eaf0e642146600c134edab647292683aaf3b4d9 /org.eclipse.jgit.junit/src | |
parent | 7eb222f20d34d026e3de9acad7275271de71f7eb (diff) | |
parent | fcfe1299c37ae8308e9d930201823b3ac340dd2b (diff) | |
download | jgit-d9c569b74725b4ffe9fa085ff1542b619cbcf4ce.tar.gz jgit-d9c569b74725b4ffe9fa085ff1542b619cbcf4ce.zip |
Merge branch 'stable-5.3' into stable-5.4
* stable-5.3:
Prepare 5.3.3-SNAPSHOT builds
JGit v5.3.2.201906051522-r
Prepare 5.1.9-SNAPSHOT builds
JGit v5.1.8.201906050907-r
Test detecting modified packfiles
Enhance fsTick() to use filesystem timer resolution
Add debug trace to measure time needed to open pack index
Extend FileSnapshot for packfiles to also use checksum to detect changes
Wait opening new packfile until it can't be racy anymore
Avoid null PackConfig in GC
Add FileSnapshot test testing recognition of file size changes
Capture reason for result of FileSnapshot#isModified
Skip FileSnapshotTest#testSimulatePackfileReplacement on Windows
Tune max heap size for tests
Fix FileSnapshotTest.testNewFileNoWait() to match its javadoc
ObjectDirectory: fix closing of obsolete packs
Update API filters for methods added to fix bugs
Bazel: Increase severity of most error-prone checks to ERROR
Enable error-prone checks by default
Add bazel options to align with gerrit's
Include filekey file attribute when comparing FileSnapshots
Measure file timestamp resolution used in FileSnapshot
Fix FileSnapshot's consideration of file size
Fix API problem filters
Fix API problem filters
Change-Id: Ie1c7e4752661aec9e1754660934921224e2408eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java | 28 |
1 files changed, 17 insertions, 11 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 48d016c064..a5270ed2b9 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 @@ -349,7 +349,8 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase { * younger modification timestamp than the modification timestamp of the * given file. This is done by touching a temporary file, reading the * lastmodified attribute and, if needed, sleeping. After sleeping this loop - * starts again until the filesystem timer has advanced enough. + * starts again until the filesystem timer has advanced enough. The + * temporary file will be created as a sibling of lastFile. * * @param lastFile * the file on which we want to wait until the filesystem timer @@ -362,21 +363,26 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase { */ public static long fsTick(File lastFile) throws InterruptedException, IOException { - long sleepTime = 64; + File tmp; FS fs = FS.DETECTED; - if (lastFile != null && !fs.exists(lastFile)) - throw new FileNotFoundException(lastFile.getPath()); - File tmp = File.createTempFile("FileTreeIteratorWithTimeControl", null); + if (lastFile == null) { + lastFile = tmp = File + .createTempFile("fsTickTmpFile", null); + } else { + if (!fs.exists(lastFile)) { + throw new FileNotFoundException(lastFile.getPath()); + } + tmp = File.createTempFile("fsTickTmpFile", null, + lastFile.getParentFile()); + } + long res = FS.getFsTimerResolution(tmp.toPath()).toMillis(); + long sleepTime = res / 10; try { - long startTime = (lastFile == null) ? fs.lastModified(tmp) : fs - .lastModified(lastFile); + long startTime = fs.lastModified(lastFile); long actTime = fs.lastModified(tmp); while (actTime <= startTime) { Thread.sleep(sleepTime); - sleepTime *= 2; - try (FileOutputStream fos = new FileOutputStream(tmp)) { - // Do nothing - } + FileUtils.touch(tmp.toPath()); actTime = fs.lastModified(tmp); } return actTime; |