aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit/src
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-08-10 23:44:39 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-08-11 00:06:03 +0200
commitc28167e1036fe132f8a66db7943d54ee8d869d34 (patch)
tree15c3aca320f4104e486f2ac1b8a8bb2fd6aee3e7 /org.eclipse.jgit.junit/src
parent12d03a97d8c2796a0728afb4e00d4d1c32b93f8b (diff)
downloadjgit-c28167e1036fe132f8a66db7943d54ee8d869d34.tar.gz
jgit-c28167e1036fe132f8a66db7943d54ee8d869d34.zip
Ensure LocalDiskRepositoryTestCase#setup fully uses MockSystemReader
FS#getFileStoreAttributes used the real userConfig and not the mocked one. This led to test errors when running tests with Bazel since it sandboxes tests which prevents they can write to ~/.gitconfig. Fix this by first preparing the MockedSystemReader and the mocked config before calling FS#getFileStoreAttributes. Also fix ConfigTest which broke due to this change since it inherits from LocalDiskRepositoryTestCase and calls its setup method which was changed here. We can no longer assert by comparing plain text since FS adds FileStoreAttributes to the mocked userConfig. Also the default options seen by this test changed since we now use a mocked config. Change-Id: I76bc7c94953fe979266147d3b309a68dda9d4dfe 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/LocalDiskRepositoryTestCase.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
index af23ad1e35..cce83c00b2 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
@@ -128,11 +128,8 @@ public abstract class LocalDiskRepositoryTestCase {
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.getFileStoreAttributes(tmp.toPath().getParent());
-
mockSystemReader = new MockSystemReader();
+ SystemReader.setInstance(mockSystemReader);
mockSystemReader.userGitConfig = new FileBasedConfig(new File(tmp,
"usergitconfig"), FS.DETECTED);
// We have to set autoDetach to false for tests, because tests expect to be able
@@ -142,7 +139,12 @@ public abstract class LocalDiskRepositoryTestCase {
null, ConfigConstants.CONFIG_KEY_AUTODETACH, false);
mockSystemReader.userGitConfig.save();
ceilTestDirectories(getCeilings());
- SystemReader.setInstance(mockSystemReader);
+
+ // Measure timer resolution before the test to avoid time critical tests
+ // are affected by time needed for measurement.
+ // The MockSystemReader must be configured first since we need to use
+ // the same one here
+ FS.getFileStoreAttributes(tmp.toPath().getParent());
author = new PersonIdent("J. Author", "jauthor@example.com");
committer = new PersonIdent("J. Committer", "jcommitter@example.com");