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>
This commit is contained in:
Matthias Sohn 2019-07-10 16:22:15 +02:00
parent 93144f1438
commit eda2e95fa8
5 changed files with 16 additions and 1 deletions

View File

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

View File

@ -127,6 +127,10 @@ public void setUp() throws Exception {
if (!tmp.delete() || !tmp.mkdir())
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.userGitConfig = new FileBasedConfig(new File(tmp,
"usergitconfig"), FS.DETECTED);

View File

@ -82,6 +82,7 @@
import org.eclipse.jgit.lfs.server.LargeFileRepository;
import org.eclipse.jgit.lfs.server.LfsProtocolServlet;
import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.IO;
import org.junit.After;
@ -119,6 +120,11 @@ public Path getDir() {
@Before
public void setup() throws Exception {
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();
ServletContextHandler app = server.addContext("/lfs");
dir = Paths.get(tmp.toString(), "lfs");

View File

@ -69,6 +69,9 @@ public class FileSnapshotTest {
@Before
public void setUp() throws Exception {
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

View File

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