diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2021-12-27 08:27:12 +0100 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2021-12-27 08:30:43 +0100 |
commit | d986d97dfa992577005e7eee872629de66acca3b (patch) | |
tree | 56e14bc55deef35a745381ced1ac826a1a658a87 /org.eclipse.jgit.test | |
parent | 6a24cdc5eac9ca351e4956f1cfbe4954d145666b (diff) | |
parent | f77519775d7cd5638be71e91f70ff11fd653e6c5 (diff) | |
download | jgit-d986d97dfa992577005e7eee872629de66acca3b.tar.gz jgit-d986d97dfa992577005e7eee872629de66acca3b.zip |
Merge branch 'master' into next
* master:
Revert "RefDirectory.scanRef: Re-use file existence check done in snapshot creation"
TreeRevFilter: fix wrong stop when the given path disappears
Add config reader for user-defined difftools
PackBitmapIndexV1: support parallel loading of reverse index
Change-Id: I7db97dabaef06e6fdbfa0e8ae7833a4b0d6f2013
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test')
3 files changed, 101 insertions, 12 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalDiffToolTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalDiffToolTest.java index f07d9d1afc..b141a86f76 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalDiffToolTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalDiffToolTest.java @@ -9,9 +9,18 @@ */ package org.eclipse.jgit.internal.diffmergetool; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_DIFFTOOL_SECTION; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_CMD; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_GUITOOL; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PATH; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PROMPT; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_TRUST_EXIT_CODE; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Map; import java.util.Set; import org.eclipse.jgit.lib.internal.BooleanTriState; @@ -29,27 +38,64 @@ public class ExternalDiffToolTest extends ExternalToolTest { Set<String> actualToolNames = manager.getToolNames(); Set<String> expectedToolNames = Collections.emptySet(); assertEquals("Incorrect set of external diff tool names", - expectedToolNames, - actualToolNames); + expectedToolNames, actualToolNames); } @Test public void testAllTools() { DiffTools manager = new DiffTools(db); Set<String> actualToolNames = manager.getAvailableTools().keySet(); - Set<String> expectedToolNames = Collections.emptySet(); - assertEquals("Incorrect set of available external diff tools", - expectedToolNames, + Set<String> expectedToolNames = new LinkedHashSet<>(); + CommandLineDiffTool[] defaultTools = CommandLineDiffTool.values(); + for (CommandLineDiffTool defaultTool : defaultTools) { + String toolName = defaultTool.name(); + expectedToolNames.add(toolName); + } + assertEquals("Incorrect set of external diff tools", expectedToolNames, actualToolNames); } @Test + public void testOverridePredefinedToolPath() { + String toolName = CommandLineDiffTool.guiffy.name(); + String customToolPath = "/usr/bin/echo"; + + FileBasedConfig config = db.getConfig(); + config.setString(CONFIG_DIFFTOOL_SECTION, toolName, CONFIG_KEY_CMD, + "echo"); + config.setString(CONFIG_DIFFTOOL_SECTION, toolName, CONFIG_KEY_PATH, + customToolPath); + + DiffTools manager = new DiffTools(db); + Map<String, ExternalDiffTool> tools = manager.getUserDefinedTools(); + ExternalDiffTool diffTool = tools.get(toolName); + assertNotNull("Expected tool \"" + toolName + "\" to be user defined", + diffTool); + + String toolPath = diffTool.getPath(); + assertEquals("Expected external diff tool to have an overriden path", + customToolPath, toolPath); + } + + @Test public void testUserDefinedTools() { + FileBasedConfig config = db.getConfig(); + String customToolname = "customTool"; + config.setString(CONFIG_DIFFTOOL_SECTION, customToolname, + CONFIG_KEY_CMD, "echo"); + config.setString(CONFIG_DIFFTOOL_SECTION, customToolname, + CONFIG_KEY_PATH, "/usr/bin/echo"); + config.setString(CONFIG_DIFFTOOL_SECTION, customToolname, + CONFIG_KEY_PROMPT, "--no-prompt"); + config.setString(CONFIG_DIFFTOOL_SECTION, customToolname, + CONFIG_KEY_GUITOOL, "--no-gui"); + config.setString(CONFIG_DIFFTOOL_SECTION, customToolname, + CONFIG_KEY_TRUST_EXIT_CODE, "--no-trust-exit-code"); DiffTools manager = new DiffTools(db); Set<String> actualToolNames = manager.getUserDefinedTools().keySet(); - Set<String> expectedToolNames = Collections.emptySet(); - assertEquals("Incorrect set of user defined external diff tools", - expectedToolNames, + Set<String> expectedToolNames = new LinkedHashSet<>(); + expectedToolNames.add(customToolname); + assertEquals("Incorrect set of external diff tools", expectedToolNames, actualToolNames); } @@ -59,8 +105,7 @@ public class ExternalDiffToolTest extends ExternalToolTest { Set<String> actualToolNames = manager.getNotAvailableTools().keySet(); Set<String> expectedToolNames = Collections.emptySet(); assertEquals("Incorrect set of not available external diff tools", - expectedToolNames, - actualToolNames); + expectedToolNames, actualToolNames); } @Test @@ -80,8 +125,7 @@ public class ExternalDiffToolTest extends ExternalToolTest { int compareResult = manager.compare(newPath, oldPath, newId, oldId, toolName, prompt, gui, trustExitCode); assertEquals("Incorrect compare result for external diff tool", - expectedCompareResult, - compareResult); + expectedCompareResult, compareResult); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheTest.java index 4f1314057f..070d666ee5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheTest.java @@ -290,6 +290,31 @@ public class DfsBlockCacheTest { assertEquals(1, cache.getMissCount()[0]); } + @SuppressWarnings("resource") + @Test + public void highConcurrencyParallelReads_oneRepoParallelReverseIndex() + throws Exception { + InMemoryRepository r1 = createRepoWithBitmap("test"); + resetCache(); + + DfsReader reader = (DfsReader) r1.newObjectReader(); + reader.getOptions().setLoadRevIndexInParallel(true); + for (DfsPackFile pack : r1.getObjectDatabase().getPacks()) { + // Only load non-garbage pack with bitmap. + if (pack.isGarbage()) { + continue; + } + asyncRun(() -> pack.getBitmapIndex(reader)); + asyncRun(() -> pack.getPackIndex(reader)); + asyncRun(() -> pack.getBitmapIndex(reader)); + } + waitForExecutorPoolTermination(); + + assertEquals(1, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]); + assertEquals(1, cache.getMissCount()[PackExt.INDEX.ordinal()]); + assertEquals(1, cache.getMissCount()[0]); + } + private void resetCache() { resetCache(32); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter1Test.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter1Test.java index 31629f3de9..5cce11aa1f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter1Test.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter1Test.java @@ -15,6 +15,7 @@ import static org.junit.Assert.assertNull; import java.util.Collections; +import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import org.eclipse.jgit.treewalk.filter.TreeFilter; @@ -253,4 +254,23 @@ public class RevWalkPathFilter1Test extends RevWalkTestCase { assertEquals(0, a.getParentCount()); assertNull(rw.next()); } + + @Test + public void testStopWhenPathDisappears() throws Exception { + DirCacheEntry file1 = file("src/d1/file1", blob("a")); + DirCacheEntry file2 = file("src/d1/file2", blob("a")); + DirCacheEntry file3 = file("src/d1/file3", blob("a")); + RevCommit a = commit(tree(file1)); + RevCommit b = commit(tree(file1, file2), a); + RevCommit c = commit(tree(file1, file3), a); + RevCommit d = commit(tree(file1, file2, file3), b, c); + filter("src/d1"); + markStart(d); + rw.setRewriteParents(false); + + assertCommit(d, rw.next()); + assertCommit(c, rw.next()); + assertCommit(b, rw.next()); + assertCommit(a, rw.next()); + } } |