Skip to content

Commit cef003d

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9d46bc7 commit cef003d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

t/test-lib-functions.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,16 @@ test_cmp () {
12681268
eval "$GIT_TEST_CMP" '"$@"'
12691269
}
12701270

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+
12711281
# Check that the given config key has the expected value.
12721282
#
12731283
# test_cmp_config [-C <dir>] <expected-value>

0 commit comments

Comments
 (0)