Skip to content

Commit ddfe900

Browse files
avargitster
authored andcommitted
test-lib-functions: move function to lib-bitmap.sh
Move a function added to test-lib-functions.sh in ea047a8 (t5310: factor out bitmap traversal comparison, 2020-02-14) into a new lib-bitmap.sh. The test-lib-functions.sh file should be for functions that are widely used across the test suite, if something's only used by a few tests it makes more sense to have it in a lib-*.sh file. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3fca1fc commit ddfe900

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

t/lib-bitmap.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Compare a file containing rev-list bitmap traversal output to its non-bitmap
2+
# counterpart. You can't just use test_cmp for this, because the two produce
3+
# subtly different output:
4+
#
5+
# - regular output is in traversal order, whereas bitmap is split by type,
6+
# with non-packed objects at the end
7+
#
8+
# - regular output has a space and the pathname appended to non-commit
9+
# objects; bitmap output omits this
10+
#
11+
# This function normalizes and compares the two. The second file should
12+
# always be the bitmap output.
13+
test_bitmap_traversal () {
14+
if test "$1" = "--no-confirm-bitmaps"
15+
then
16+
shift
17+
elif cmp "$1" "$2"
18+
then
19+
echo >&2 "identical raw outputs; are you sure bitmaps were used?"
20+
return 1
21+
fi &&
22+
cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
23+
sort "$2" >"$2.normalized" &&
24+
test_cmp "$1.normalized" "$2.normalized" &&
25+
rm -f "$1.normalized" "$2.normalized"
26+
}

t/t5310-pack-bitmaps.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

77
. ./test-lib.sh
8+
. "$TEST_DIRECTORY"/lib-bundle.sh
9+
. "$TEST_DIRECTORY"/lib-bitmap.sh
810

911
objpath () {
1012
echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"

t/t6113-rev-list-bitmap-filters.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='rev-list combining bitmaps and filters'
44
. ./test-lib.sh
5+
. "$TEST_DIRECTORY"/lib-bitmap.sh
56

67
test_expect_success 'set up bitmapped repo' '
78
# one commit will have bitmaps, the other will not

t/test-lib-functions.sh

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,33 +1602,6 @@ test_set_port () {
16021602
eval $var=$port
16031603
}
16041604

1605-
# Compare a file containing rev-list bitmap traversal output to its non-bitmap
1606-
# counterpart. You can't just use test_cmp for this, because the two produce
1607-
# subtly different output:
1608-
#
1609-
# - regular output is in traversal order, whereas bitmap is split by type,
1610-
# with non-packed objects at the end
1611-
#
1612-
# - regular output has a space and the pathname appended to non-commit
1613-
# objects; bitmap output omits this
1614-
#
1615-
# This function normalizes and compares the two. The second file should
1616-
# always be the bitmap output.
1617-
test_bitmap_traversal () {
1618-
if test "$1" = "--no-confirm-bitmaps"
1619-
then
1620-
shift
1621-
elif cmp "$1" "$2"
1622-
then
1623-
echo >&2 "identical raw outputs; are you sure bitmaps were used?"
1624-
return 1
1625-
fi &&
1626-
cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
1627-
sort "$2" >"$2.normalized" &&
1628-
test_cmp "$1.normalized" "$2.normalized" &&
1629-
rm -f "$1.normalized" "$2.normalized"
1630-
}
1631-
16321605
# Tests for the hidden file attribute on Windows
16331606
test_path_is_hidden () {
16341607
test_have_prereq MINGW ||

0 commit comments

Comments
 (0)