Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2023-07-11 00:12:31 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-11 00:48:55 +0300
commitc489f47a649da8984a2240032e1d819e9a80ea2a (patch)
tree1d87922b2067d0566ee39f9ec2b85a0616312c83 /t/t1419-exclude-refs.sh
parent59c35fac54054b3f781b0275eac7d7c54468f0d5 (diff)
refs/packed-backend.c: add trace2 counters for jump list
The previous commit added low-level tests to ensure that the packed-refs iterator did not enumerate excluded sections of the refspace. However, there was no guarantee that these sections weren't being visited, only that they were being suppressed from the output. To harden these tests, add a trace2 counter which tracks the number of regions skipped by the packed-refs iterator, and assert on its value. Suggested-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1419-exclude-refs.sh')
-rwxr-xr-xt/t1419-exclude-refs.sh59
1 files changed, 40 insertions, 19 deletions
diff --git a/t/t1419-exclude-refs.sh b/t/t1419-exclude-refs.sh
index bc534c8ea1..5d8c86b657 100755
--- a/t/t1419-exclude-refs.sh
+++ b/t/t1419-exclude-refs.sh
@@ -9,7 +9,8 @@ TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
for_each_ref__exclude () {
- test-tool ref-store main for-each-ref--exclude "$@" >actual.raw
+ GIT_TRACE2_PERF=1 test-tool ref-store main \
+ for-each-ref--exclude "$@" >actual.raw
cut -d ' ' -f 2 actual.raw
}
@@ -17,6 +18,17 @@ for_each_ref () {
git for-each-ref --format='%(refname)' "$@"
}
+assert_jumps () {
+ local nr="$1"
+ local trace="$2"
+
+ grep -q "name:jumps_made value:$nr$" $trace
+}
+
+assert_no_jumps () {
+ ! assert_jumps ".*" "$1"
+}
+
test_expect_success 'setup' '
test_commit --no-tag base &&
base="$(git rev-parse HEAD)" &&
@@ -35,67 +47,76 @@ test_expect_success 'setup' '
'
test_expect_success 'excluded region in middle' '
- for_each_ref__exclude refs/heads refs/heads/foo >actual &&
+ for_each_ref__exclude refs/heads refs/heads/foo >actual 2>perf &&
for_each_ref refs/heads/bar refs/heads/baz refs/heads/quux >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_jumps 1 perf
'
test_expect_success 'excluded region at beginning' '
- for_each_ref__exclude refs/heads refs/heads/bar >actual &&
+ for_each_ref__exclude refs/heads refs/heads/bar >actual 2>perf &&
for_each_ref refs/heads/baz refs/heads/foo refs/heads/quux >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_jumps 1 perf
'
test_expect_success 'excluded region at end' '
- for_each_ref__exclude refs/heads refs/heads/quux >actual &&
+ for_each_ref__exclude refs/heads refs/heads/quux >actual 2>perf &&
for_each_ref refs/heads/foo refs/heads/bar refs/heads/baz >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_jumps 1 perf
'
test_expect_success 'disjoint excluded regions' '
- for_each_ref__exclude refs/heads refs/heads/bar refs/heads/quux >actual &&
+ for_each_ref__exclude refs/heads refs/heads/bar refs/heads/quux >actual 2>perf &&
for_each_ref refs/heads/baz refs/heads/foo >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_jumps 2 perf
'
test_expect_success 'adjacent, non-overlapping excluded regions' '
- for_each_ref__exclude refs/heads refs/heads/bar refs/heads/baz >actual &&
+ for_each_ref__exclude refs/heads refs/heads/bar refs/heads/baz >actual 2>perf &&
for_each_ref refs/heads/foo refs/heads/quux >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_jumps 1 perf
'
test_expect_success 'overlapping excluded regions' '
- for_each_ref__exclude refs/heads refs/heads/ba refs/heads/baz >actual &&
+ for_each_ref__exclude refs/heads refs/heads/ba refs/heads/baz >actual 2>perf &&
for_each_ref refs/heads/foo refs/heads/quux >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_jumps 1 perf
'
test_expect_success 'several overlapping excluded regions' '
for_each_ref__exclude refs/heads \
- refs/heads/bar refs/heads/baz refs/heads/foo >actual &&
+ refs/heads/bar refs/heads/baz refs/heads/foo >actual 2>perf &&
for_each_ref refs/heads/quux >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_jumps 1 perf
'
test_expect_success 'non-matching excluded section' '
- for_each_ref__exclude refs/heads refs/heads/does/not/exist >actual &&
+ for_each_ref__exclude refs/heads refs/heads/does/not/exist >actual 2>perf &&
for_each_ref >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_no_jumps perf
'
test_expect_success 'meta-characters are discarded' '
- for_each_ref__exclude refs/heads "refs/heads/ba*" >actual &&
+ for_each_ref__exclude refs/heads "refs/heads/ba*" >actual 2>perf &&
for_each_ref >expect &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ assert_no_jumps perf
'
test_done