summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-08-04 07:42:31 -0300
committerDavid Bremner <david@tethera.net>2021-08-21 14:55:27 -0700
commit78045301e7dd3caf82d5efc241d10b351be33b28 (patch)
tree3fd4eacc067c10059169dd063d5e70101ed28049
parentf2e6f311c7b4bf4c459c7e73c8a8d3fe157851c4 (diff)
test: factor out test_diff_file_
A following commit will use this new function in a public test function.
-rw-r--r--test/test-lib.sh24
1 files changed, 14 insertions, 10 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 1f696c44..6f4bb47f 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -402,17 +402,8 @@ test_expect_equal () {
fi
}
-# Like test_expect_equal, but takes two filenames.
-test_expect_equal_file () {
+test_diff_file_ () {
local file1 file2 testname basename1 basename2
- exec 1>&6 2>&7 # Restore stdout and stderr
- if [ -z "$inside_subtest" ]; then
- error "bug in the test script: test_expect_equal_file without test_begin_subtest"
- fi
- inside_subtest=
- test "$#" = 2 ||
- error "bug in the test script: not 2 parameters to test_expect_equal_file"
-
file1="$1"
file2="$2"
if ! test_skip "$test_subtest_name"
@@ -430,6 +421,19 @@ test_expect_equal_file () {
fi
}
+# Like test_expect_equal, but takes two filenames.
+test_expect_equal_file () {
+ exec 1>&6 2>&7 # Restore stdout and stderr
+ if [ -z "$inside_subtest" ]; then
+ error "bug in the test script: test_expect_equal_file without test_begin_subtest"
+ fi
+ inside_subtest=
+ test "$#" = 2 ||
+ error "bug in the test script: not 2 parameters to test_expect_equal_file"
+
+ test_diff_file_ "$1" "$2"
+}
+
# Like test_expect_equal, but arguments are JSON expressions to be
# canonicalized before diff'ing. If an argument cannot be parsed, it
# is used unchanged so that there's something to diff against.