aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-08-08 10:10:12 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-08-08 10:10:12 +0200
commit5a88815b1ceb3db7eaf46d22f20fa20270f6f7c4 (patch)
treeabf5a9b5ed37a71d66ee3b1a167651dda712fd98
parente60b9e1879f8774e1afe07be4224605045f49eec (diff)
downloadjgit-5a88815b1ceb3db7eaf46d22f20fa20270f6f7c4.tar.gz
jgit-5a88815b1ceb3db7eaf46d22f20fa20270f6f7c4.zip
Fix OpenSshConfigTest#config
- use FS.DETECTED instead of db.getFS() since the ssh config is typically in a different place than the repository, the same is used in OpenSshConfig - reduce unnecessary repeated writes by introducing wait for one tick of the file time resolution Change-Id: Ifac915e97ff420ec5cf8e2f162e351f9f51b6b14 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
index 7777a3c993..0358718cf2 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
@@ -58,6 +58,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.time.Instant;
+import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.lib.Constants;
@@ -93,12 +94,17 @@ public class OpenSshConfigTest extends RepositoryTestCase {
}
private void config(String data) throws IOException {
- FS fs = db.getFS();
+ FS fs = FS.DETECTED;
+ long resolution = FS.getFileStoreAttributes(configFile.toPath())
+ .getFsTimestampResolution().toNanos();
Instant lastMtime = fs.lastModifiedInstant(configFile);
do {
try (final OutputStreamWriter fw = new OutputStreamWriter(
new FileOutputStream(configFile), UTF_8)) {
fw.write(data);
+ TimeUnit.NANOSECONDS.sleep(resolution);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
}
} while (lastMtime.equals(fs.lastModifiedInstant(configFile)));
}