@matheusbsbs / matheus-bagliano / commits / ea047a8eb4
Fork 0

t5310: factor out bitmap traversal comparison

We check the results of "rev-list --use-bitmap-index" by comparing it to the same traversal without the bitmap option. However, this is a little tricky to do because of some output differences (see the included comment for details). Let's pull this out into a helper function, since we'll be adding some similar tests. While we're at it, let's also try to confirm that the bitmap output did indeed use bitmaps. Since the code internally falls back to the non-bitmap path in some cases, the tests are at risk of becoming trivial noops. This is a bit fragile, as not all outputs will differ (e.g., looking at only the commits from a fully-bitmapped pack will end up exactly the same as the normal traversal order, since it also matches the pack order). So we'll provide an escape hatch by which tests can disable this check (which should only be used after manually confirming that bitmaps kicked in). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 14, 2020 at 13:22 UTC ea047a8eb4f45c1c4e3c9b1af919bf0361ac1b7c
2 files changed +30 -7
t/t5310-pack-bitmaps.sh
+3 -7
@@ -81,13 +81,9 @@ rev_list_tests() {
81 '
82
83 test_expect_success "enumerate --objects ($state)" '
84 - git rev-list --objects --use-bitmap-index HEAD >tmp &&
85 - cut -d" " -f1 <tmp >tmp2 &&
86 - sort <tmp2 >actual &&
87 - git rev-list --objects HEAD >tmp &&
88 - cut -d" " -f1 <tmp >tmp2 &&
89 - sort <tmp2 >expect &&
90 - test_cmp expect actual
84 + git rev-list --objects --use-bitmap-index HEAD >actual &&
85 + git rev-list --objects HEAD >expect &&
86 + test_bitmap_traversal expect actual
87 '
88
89 test_expect_success "bitmap --objects handles non-commit objects ($state)" '
t/test-lib-functions.sh
+27
@@ -1516,3 +1516,30 @@ test_set_port () {
1516 port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
1517 eval $var=$port
1518 }
1519 +
1520 +# Compare a file containing rev-list bitmap traversal output to its non-bitmap
1521 +# counterpart. You can't just use test_cmp for this, because the two produce
1522 +# subtly different output:
1523 +#
1524 +# - regular output is in traversal order, whereas bitmap is split by type,
1525 +# with non-packed objects at the end
1526 +#
1527 +# - regular output has a space and the pathname appended to non-commit
1528 +# objects; bitmap output omits this
1529 +#
1530 +# This function normalizes and compares the two. The second file should
1531 +# always be the bitmap output.
1532 +test_bitmap_traversal () {
1533 + if test "$1" = "--no-confirm-bitmaps"
1534 + then
1535 + shift
1536 + elif cmp "$1" "$2"
1537 + then
1538 + echo >&2 "identical raw outputs; are you sure bitmaps were used?"
1539 + return 1
1540 + fi &&
1541 + cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
1542 + sort "$2" >"$2.normalized" &&
1543 + test_cmp "$1.normalized" "$2.normalized" &&
1544 + rm -f "$1.normalized" "$2.normalized"
1545 +}