]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/lib-bitmap.sh: parameterize tests over reverse index source
authorTaylor Blau <me@ttaylorr.com>
Tue, 25 Jan 2022 22:41:15 +0000 (17:41 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Jan 2022 20:07:53 +0000 (12:07 -0800)
To prepare for reading the reverse index data out of the MIDX itself,
teach the `test_rev_exists` function to take an expected "source" for
the reverse index data.

When given "rev", it asserts that the MIDX's `.rev` file exists, and is
loaded when verifying the integrity of its bitmaps. Otherwise, it
ensures that trace2 reports the source of the reverse index data as the
same string which was given to test_rev_exists().

The following patch will implement reading the reverse index data from
the MIDX itself.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-bitmap.sh

index 48a8730a13ee3c61d2c30a847a7af01e91484c14..253895c04ed8fb7bcd6fcb20b216eb51327c186a 100644 (file)
@@ -275,17 +275,23 @@ midx_pack_source () {
 
 test_rev_exists () {
        commit="$1"
+       kind="$2"
 
-       test_expect_success 'reverse index exists' '
+       test_expect_success "reverse index exists ($kind)" '
                GIT_TRACE2_EVENT=$(pwd)/event.trace \
                        git rev-list --test-bitmap "$commit" &&
 
-               test_path_is_file $midx-$(midx_checksum $objdir).rev &&
-               grep "\"category\":\"load_midx_revindex\",\"key\":\"source\",\"value\":\"rev\"" event.trace
+               if test "rev" = "$kind"
+               then
+                       test_path_is_file $midx-$(midx_checksum $objdir).rev
+               fi &&
+               grep "\"category\":\"load_midx_revindex\",\"key\":\"source\",\"value\":\"$kind\"" event.trace
        '
 }
 
 midx_bitmap_core () {
+       rev_kind="${1:-rev}"
+
        setup_bitmap_history
 
        test_expect_success 'create single-pack midx with bitmaps' '
@@ -295,7 +301,7 @@ midx_bitmap_core () {
                test_path_is_file $midx-$(midx_checksum $objdir).bitmap
        '
 
-       test_rev_exists HEAD
+       test_rev_exists HEAD "$rev_kind"
 
        basic_bitmap_tests
 
@@ -325,7 +331,7 @@ midx_bitmap_core () {
                test_path_is_file $midx-$(midx_checksum $objdir).bitmap
        '
 
-       test_rev_exists HEAD
+       test_rev_exists HEAD "$rev_kind"
 
        basic_bitmap_tests
 
@@ -428,6 +434,8 @@ midx_bitmap_core () {
 }
 
 midx_bitmap_partial_tests () {
+       rev_kind="${1:-rev}"
+
        test_expect_success 'setup partial bitmaps' '
                test_commit packed &&
                git repack &&
@@ -437,7 +445,7 @@ midx_bitmap_partial_tests () {
                test_path_is_file $midx-$(midx_checksum $objdir).bitmap
        '
 
-       test_rev_exists HEAD~
+       test_rev_exists HEAD~ "$rev_kind"
 
        basic_bitmap_tests HEAD~
 }