Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2017-06-07 10:53:09 -0400
committerMatthias Sohn2017-06-07 17:59:34 -0400
commit10e2977f5f64676d5b64ceb41b7d406e9dd58bde (patch)
treec5df0d4a3c8dd105754042bd7cb9bf43f6c8fa61 /org.eclipse.egit.core.test/src
parent9ee41054835597f90a17cb2bc9c15123b586af65 (diff)
downloadegit-10e2977f5f64676d5b64ceb41b7d406e9dd58bde.tar.gz
egit-10e2977f5f64676d5b64ceb41b7d406e9dd58bde.tar.xz
egit-10e2977f5f64676d5b64ceb41b7d406e9dd58bde.zip
Disable running autoGC in the background for EGit tests
If autoGC runs in the background this may lead to cleanup issues when tests are teared down. Change-Id: Ib6b6b6b9f8b70abf7ea3defa7b4fe6854b31e9cb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
index a48bd2f55..b14ed3604 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java
@@ -21,10 +21,14 @@ import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.GitCorePreferences;
import org.eclipse.jgit.junit.MockSystemReader;
+import org.eclipse.jgit.lib.Config;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileBasedConfig;
+import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.SystemReader;
@@ -54,11 +58,27 @@ public abstract class GitTestCase {
// ensure there are no shared Repository instances left
// when starting a new test
Activator.getDefault().getRepositoryCache().clear();
- MockSystemReader mockSystemReader = new MockSystemReader();
+ File configFile = File.createTempFile("gitconfigtest", "config");
+ MockSystemReader mockSystemReader = new MockSystemReader() {
+ @Override
+ public FileBasedConfig openUserConfig(Config parent, FS fs) {
+ return new FileBasedConfig(parent, configFile, fs);
+ }
+ };
+ configFile.deleteOnExit();
SystemReader.setInstance(mockSystemReader);
mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY,
ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile()
.getParentFile().getAbsoluteFile().toString());
+ FileBasedConfig userConfig = mockSystemReader.openUserConfig(null,
+ FS.DETECTED);
+ // We have to set autoDetach to false for tests, because tests expect to
+ // be able to clean up by recursively removing the repository, and
+ // background GC might be in the middle of writing or deleting files,
+ // which would disrupt this.
+ userConfig.setBoolean(ConfigConstants.CONFIG_GC_SECTION, null,
+ ConfigConstants.CONFIG_KEY_AUTODETACH, false);
+ userConfig.save();
project = new TestProject(true);
gitDir = new File(project.getProject().getWorkspace().getRoot()
.getRawLocation().toFile(), Constants.DOT_GIT);

Back to the top