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 <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Dec 20, 2024 at 16:21 UTC
cef003d4532d4dff26007c0cd50afcfef84ad33b
1 file changed
+10
t/test-lib-functions.sh
+10
@@ -1268,6 +1268,16 @@ test_cmp () {
1268
eval "$GIT_TEST_CMP" '"$@"'
1269
}
1270
1271
+# test_cmp_sorted runs test_cmp on sorted versions of the two
1272
+# input files. Uses "$1.sorted" and "$2.sorted" as temp files.
1273
+
1274
+test_cmp_sorted () {
1275
+ sort <"$1" >"$1.sorted" &&
1276
+ sort <"$2" >"$2.sorted" &&
1277
+ test_cmp "$1.sorted" "$2.sorted" &&
1278
+ rm "$1.sorted" "$2.sorted"
1279
+}
1280
+
1281
# Check that the given config key has the expected value.
1282
#
1283
# test_cmp_config [-C <dir>] <expected-value>