t/lib-bitmap.sh: parameterize tests over reverse index source
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>
Taylor Blau committed
Jan 25, 2022 at 17:41 UTC
a80f0f91b1d6586abe0b37d19c0bd60ce1843571
1 file changed
+14
-6
t/lib-bitmap.sh
+14
-6
@@ -275,17 +275,23 @@ midx_pack_source () {
275
276
test_rev_exists () {
277
commit="$1"
278
+ kind="$2"
279
279
- test_expect_success 'reverse index exists' '
280
+ test_expect_success "reverse index exists ($kind)" '
281
GIT_TRACE2_EVENT=$(pwd)/event.trace \
282
git rev-list --test-bitmap "$commit" &&
283
283
- test_path_is_file $midx-$(midx_checksum $objdir).rev &&
284
- grep "\"category\":\"load_midx_revindex\",\"key\":\"source\",\"value\":\"rev\"" event.trace
284
+ if test "rev" = "$kind"
285
+ then
286
+ test_path_is_file $midx-$(midx_checksum $objdir).rev
287
+ fi &&
288
+ grep "\"category\":\"load_midx_revindex\",\"key\":\"source\",\"value\":\"$kind\"" event.trace
289
'
290
}
291
292
midx_bitmap_core () {
293
+ rev_kind="${1:-rev}"
294
+
295
setup_bitmap_history
296
297
test_expect_success 'create single-pack midx with bitmaps' '
@@ -295,7 +301,7 @@ midx_bitmap_core () {
301
test_path_is_file $midx-$(midx_checksum $objdir).bitmap
302
'
303
298
- test_rev_exists HEAD
304
+ test_rev_exists HEAD "$rev_kind"
305
306
basic_bitmap_tests
307
@@ -325,7 +331,7 @@ midx_bitmap_core () {
331
test_path_is_file $midx-$(midx_checksum $objdir).bitmap
332
'
333
328
- test_rev_exists HEAD
334
+ test_rev_exists HEAD "$rev_kind"
335
336
basic_bitmap_tests
337
@@ -428,6 +434,8 @@ midx_bitmap_core () {
434
}
435
436
midx_bitmap_partial_tests () {
437
+ rev_kind="${1:-rev}"
438
+
439
test_expect_success 'setup partial bitmaps' '
440
test_commit packed &&
441
git repack &&
@@ -437,7 +445,7 @@ midx_bitmap_partial_tests () {
445
test_path_is_file $midx-$(midx_checksum $objdir).bitmap
446
'
447
440
- test_rev_exists HEAD~
448
+ test_rev_exists HEAD~ "$rev_kind"
449
450
basic_bitmap_tests HEAD~
451
}