Skip to content

Commit cf2ed61

Browse files
committed
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]>
1 parent b7e9b81 commit cf2ed61

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
@@ -1267,6 +1267,16 @@ test_cmp () {
12671267
eval "$GIT_TEST_CMP" '"$@"'
12681268
}
12691269

1270+
# test_cmp_sorted runs test_cmp on sorted versions of the two
1271+
# input files. Uses "$1.sorted" and "$2.sorted" as temp files.
1272+
1273+
test_cmp_sorted () {
1274+
sort <"$1" >"$1.sorted" &&
1275+
sort <"$2" >"$2.sorted" &&
1276+
test_cmp "$1.sorted" "$2.sorted" &&
1277+
rm "$1.sorted" "$2.sorted"
1278+
}
1279+
12701280
# Check that the given config key has the expected value.
12711281
#
12721282
# test_cmp_config [-C <dir>] <expected-value>

0 commit comments

Comments
 (0)