aboutsummaryrefslogtreecommitdiffstats
path: root/t/lib-bitmap.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-02-22 16:12:43 -0800
committerJunio C Hamano <gitster@pobox.com>2021-02-22 16:12:43 -0800
commitd68fccef86af1ceb5ae3a9abb02c8fe4f6ff3317 (patch)
tree020527039643bd7dcf1c498e6d1c90b2aabc612d /t/lib-bitmap.sh
parentMerge branch 'ab/diff-deferred-free' (diff)
parenttest-lib-functions: assert correct parameter count (diff)
downloadgit-d68fccef86af1ceb5ae3a9abb02c8fe4f6ff3317.tar.gz
git-d68fccef86af1ceb5ae3a9abb02c8fe4f6ff3317.zip
Merge branch 'ab/test-lib'
Test framework clean-up. * ab/test-lib: test-lib-functions: assert correct parameter count test-lib-functions: remove bug-inducing "diagnostics" helper param test libs: rename "diff-lib" to "lib-diff" t/.gitattributes: sort lines test-lib-functions: move function to lib-bitmap.sh test libs: rename gitweb-lib.sh to lib-gitweb.sh test libs: rename bundle helper to "lib-bundle.sh" test-lib-functions: remove generate_zero_bytes() wrapper test-lib-functions: move test_set_index_version() to its user test lib: change "error" to "BUG" as appropriate test-lib: remove check_var_migration
Diffstat (limited to 't/lib-bitmap.sh')
-rw-r--r--t/lib-bitmap.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/t/lib-bitmap.sh b/t/lib-bitmap.sh
new file mode 100644
index 0000000000..fe3f98be24
--- /dev/null
+++ b/t/lib-bitmap.sh
@@ -0,0 +1,26 @@
+# Compare a file containing rev-list bitmap traversal output to its non-bitmap
+# counterpart. You can't just use test_cmp for this, because the two produce
+# subtly different output:
+#
+# - regular output is in traversal order, whereas bitmap is split by type,
+# with non-packed objects at the end
+#
+# - regular output has a space and the pathname appended to non-commit
+# objects; bitmap output omits this
+#
+# This function normalizes and compares the two. The second file should
+# always be the bitmap output.
+test_bitmap_traversal () {
+ if test "$1" = "--no-confirm-bitmaps"
+ then
+ shift
+ elif cmp "$1" "$2"
+ then
+ echo >&2 "identical raw outputs; are you sure bitmaps were used?"
+ return 1
+ fi &&
+ cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
+ sort "$2" >"$2.normalized" &&
+ test_cmp "$1.normalized" "$2.normalized" &&
+ rm -f "$1.normalized" "$2.normalized"
+}