Browse Source

Measure filesystem timestamp resolution already in test setup

This helps to avoid some time critical tests can't prepare the test
fixture intended since measuring timestamp resolution takes time.

Change-Id: Ib34023e682a106070ca97e98ef16789a4dfb97b4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.1
Matthias Sohn 5 years ago
parent
commit
eda2e95fa8
  1. 3
      org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java
  2. 4
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
  3. 6
      org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/LfsServerTest.java
  4. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java
  5. 1
      org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java

3
org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java

@ -65,12 +65,13 @@ public class GitCloneTaskTest extends LocalDiskRepositoryTestCase {
@Before @Before
public void before() throws IOException { public void before() throws IOException {
dest = createTempFile();
FS.getFsTimerResolution(dest.toPath().getParent());
project = new Project(); project = new Project();
project.init(); project.init();
enableLogging(); enableLogging();
project.addTaskDefinition("git-clone", GitCloneTask.class); project.addTaskDefinition("git-clone", GitCloneTask.class);
task = (GitCloneTask) project.createTask("git-clone"); task = (GitCloneTask) project.createTask("git-clone");
dest = createTempFile();
task.setDest(dest); task.setDest(dest);
} }

4
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java

@ -127,6 +127,10 @@ public abstract class LocalDiskRepositoryTestCase {
if (!tmp.delete() || !tmp.mkdir()) if (!tmp.delete() || !tmp.mkdir())
throw new IOException("Cannot create " + tmp); throw new IOException("Cannot create " + tmp);
// measure timer resolution before the test to avoid time critical tests
// are affected by time needed for measurement
FS.getFsTimerResolution(tmp.toPath().getParent());
mockSystemReader = new MockSystemReader(); mockSystemReader = new MockSystemReader();
mockSystemReader.userGitConfig = new FileBasedConfig(new File(tmp, mockSystemReader.userGitConfig = new FileBasedConfig(new File(tmp,
"usergitconfig"), FS.DETECTED); "usergitconfig"), FS.DETECTED);

6
org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/LfsServerTest.java

@ -82,6 +82,7 @@ import org.eclipse.jgit.lfs.lib.LongObjectId;
import org.eclipse.jgit.lfs.server.LargeFileRepository; import org.eclipse.jgit.lfs.server.LargeFileRepository;
import org.eclipse.jgit.lfs.server.LfsProtocolServlet; import org.eclipse.jgit.lfs.server.LfsProtocolServlet;
import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils; import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils; import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.IO;
import org.junit.After; import org.junit.After;
@ -119,6 +120,11 @@ public abstract class LfsServerTest {
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
tmp = Files.createTempDirectory("jgit_test_"); tmp = Files.createTempDirectory("jgit_test_");
// measure timer resolution before the test to avoid time critical tests
// are affected by time needed for measurement
FS.getFsTimerResolution(tmp.getParent());
server = new AppServer(); server = new AppServer();
ServletContextHandler app = server.addContext("/lfs"); ServletContextHandler app = server.addContext("/lfs");
dir = Paths.get(tmp.toString(), "lfs"); dir = Paths.get(tmp.toString(), "lfs");

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java

@ -69,6 +69,9 @@ public class FileSnapshotTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
trash = Files.createTempDirectory("tmp_"); trash = Files.createTempDirectory("tmp_");
// measure timer resolution before the test to avoid time critical tests
// are affected by time needed for measurement
FS.getFsTimerResolution(trash.getParent());
} }
@Before @Before

1
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java

@ -83,6 +83,7 @@ public class FileBasedConfigTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
trash = Files.createTempDirectory("tmp_"); trash = Files.createTempDirectory("tmp_");
FS.getFsTimerResolution(trash.getParent());
} }
@After @After

Loading…
Cancel
Save