Skip to content

Commit a80f0f9

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 791170f commit a80f0f9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

t/lib-bitmap.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,23 @@ midx_pack_source () {
275275

276276
test_rev_exists () {
277277
commit="$1"
278+
kind="$2"
278279

279-
test_expect_success 'reverse index exists' '
280+
test_expect_success "reverse index exists ($kind)" '
280281
GIT_TRACE2_EVENT=$(pwd)/event.trace \
281282
git rev-list --test-bitmap "$commit" &&
282283
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
285289
'
286290
}
287291

288292
midx_bitmap_core () {
293+
rev_kind="${1:-rev}"
294+
289295
setup_bitmap_history
290296

291297
test_expect_success 'create single-pack midx with bitmaps' '
@@ -295,7 +301,7 @@ midx_bitmap_core () {
295301
test_path_is_file $midx-$(midx_checksum $objdir).bitmap
296302
'
297303

298-
test_rev_exists HEAD
304+
test_rev_exists HEAD "$rev_kind"
299305

300306
basic_bitmap_tests
301307

@@ -325,7 +331,7 @@ midx_bitmap_core () {
325331
test_path_is_file $midx-$(midx_checksum $objdir).bitmap
326332
'
327333

328-
test_rev_exists HEAD
334+
test_rev_exists HEAD "$rev_kind"
329335

330336
basic_bitmap_tests
331337

@@ -428,6 +434,8 @@ midx_bitmap_core () {
428434
}
429435

430436
midx_bitmap_partial_tests () {
437+
rev_kind="${1:-rev}"
438+
431439
test_expect_success 'setup partial bitmaps' '
432440
test_commit packed &&
433441
git repack &&
@@ -437,7 +445,7 @@ midx_bitmap_partial_tests () {
437445
test_path_is_file $midx-$(midx_checksum $objdir).bitmap
438446
'
439447

440-
test_rev_exists HEAD~
448+
test_rev_exists HEAD~ "$rev_kind"
441449

442450
basic_bitmap_tests HEAD~
443451
}

0 commit comments

Comments
 (0)