Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2017-06-08 13:30:45 +0000
committerMatthias Sohn2017-06-08 20:16:44 +0000
commit3fff4b2f8ca7454e4da724a9f32ccc52396be4e8 (patch)
tree501386b2c5f2be30a5635ada61368097bb086557
parent5e646d20c078cdc2988c0bf5956bb03ce773c71a (diff)
parentcce1221c60cb12fadeb045b544706fc1311d7a17 (diff)
downloadegit-3fff4b2f8ca7454e4da724a9f32ccc52396be4e8.tar.gz
egit-3fff4b2f8ca7454e4da724a9f32ccc52396be4e8.tar.xz
egit-3fff4b2f8ca7454e4da724a9f32ccc52396be4e8.zip
Merge branch 'stable-4.7' into stable-4.8
* stable-4.7: Prepare 4.7.2-SNAPSHOT builds EGit v4.7.1.201706071930-r Disable running autoGC in the background for EGit tests Change-Id: Ia2fea92792b262083a7bd4ff9e608f80ec310748 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitTestCase.java22
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java47
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java3
3 files changed, 54 insertions, 18 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 a48bd2f55c..b14ed3604d 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);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
index 932a79d22f..04713a8706 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
@@ -59,14 +59,18 @@ import org.eclipse.egit.ui.test.Eclipse;
import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jface.dialogs.IDialogConstants;
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.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
+import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.SystemReader;
@@ -198,6 +202,33 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
IEclipsePreferences p = InstanceScope.INSTANCE
.getNode(Activator.getPluginId());
p.put(GitCorePreferences.core_defaultRepositoryDir, repoRoot.getPath());
+
+ File configFile = File.createTempFile("gitconfigtest", "config");
+ MockSystemReader mockSystemReader = new MockSystemReader() {
+ @Override
+ public FileBasedConfig openUserConfig(Config parent, FS fs) {
+ return new FileBasedConfig(parent, configFile, fs);
+ }
+ };
+ // unset git user properties
+ mockSystemReader.setProperty(Constants.GIT_AUTHOR_NAME_KEY, null);
+ mockSystemReader.setProperty(Constants.GIT_AUTHOR_EMAIL_KEY, null);
+ mockSystemReader.setProperty(Constants.GIT_COMMITTER_NAME_KEY, null);
+ mockSystemReader.setProperty(Constants.GIT_COMMITTER_EMAIL_KEY, null);
+ 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();
}
@After
@@ -234,21 +265,6 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
.setValue(UIPreferences.SHOW_DETACHED_HEAD_WARNING,
false);
closeGitViews();
- MockSystemReader reader = new MockSystemReader();
- // Explicitly define an empty environment
- reader.setProperty(Constants.GIT_AUTHOR_NAME_KEY, null);
- reader.setProperty(Constants.GIT_AUTHOR_EMAIL_KEY, null);
- reader.setProperty(Constants.GIT_COMMITTER_NAME_KEY, null);
- reader.setProperty(Constants.GIT_COMMITTER_EMAIL_KEY, null);
- reader.setProperty(Constants.GIT_CONFIG_NOSYSTEM_KEY, null);
- reader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY, null);
- reader.setProperty(Constants.GIT_DIR_KEY, null);
- reader.setProperty(Constants.GIT_WORK_TREE_KEY, null);
- reader.setProperty(Constants.GIT_INDEX_FILE_KEY, null);
- reader.setProperty(Constants.GIT_OBJECT_DIRECTORY_KEY, null);
- reader.setProperty(Constants.GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY,
- null);
- SystemReader.setInstance(reader);
}
@AfterClass
@@ -264,7 +280,6 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
| FileUtils.RECURSIVE | FileUtils.RETRY);
}
testUtils.deleteTempDirs();
- SystemReader.setInstance(null);
}
protected static void shutDownRepositories() throws Exception {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java
index 28a9e1351c..44ae289513 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/httpauth/PushTest.java
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.op.CloneOperation;
import org.eclipse.egit.ui.common.EGitTestCase;
@@ -60,7 +61,7 @@ public class PushTest extends EGitTestCase {
cloneOperation
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
"agitter", "letmein"));
- cloneOperation.run(null);
+ cloneOperation.run(new NullProgressMonitor());
file = new File(localRepoPath, SampleTestRepository.A_txt_name);
assertTrue(file.exists());
localRepository = Activator.getDefault().getRepositoryCache()

Back to the top