From: Derrick Stolee Date: Fri, 20 Dec 2024 16:21:10 +0000 (+0000) Subject: test-lib-functions: add test_cmp_sorted X-Git-Tag: v2.49.0-rc0~74^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cef003d4532d4dff26007c0cd50afcfef84ad33b;p=thirdparty%2Fgit.git test-lib-functions: add test_cmp_sorted 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 Signed-off-by: Junio C Hamano --- diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 78e054ab50..c17f6b05c9 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -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 ]