]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-lib-functions: add test_cmp_sorted
authorDerrick Stolee <stolee@gmail.com>
Fri, 20 Dec 2024 16:21:10 +0000 (16:21 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Dec 2024 16:37:04 +0000 (08:37 -0800)
This test helper will be helpful to reduce repeated logic in
t6601-path-walk.sh, but may be helpful elsewhere, too.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib-functions.sh

index 78e054ab503a6573ca9810a19d89afff334c6ba2..c17f6b05c9b4afcf2c2e0fbc5e8151375cee152d 100644 (file)
@@ -1268,6 +1268,16 @@ test_cmp () {
        eval "$GIT_TEST_CMP" '"$@"'
 }
 
+# test_cmp_sorted runs test_cmp on sorted versions of the two
+# input files. Uses "$1.sorted" and "$2.sorted" as temp files.
+
+test_cmp_sorted () {
+       sort <"$1" >"$1.sorted" &&
+       sort <"$2" >"$2.sorted" &&
+       test_cmp "$1.sorted" "$2.sorted" &&
+       rm "$1.sorted" "$2.sorted"
+}
+
 # Check that the given config key has the expected value.
 #
 #    test_cmp_config [-C <dir>] <expected-value>