[PATCH 3/8] test: factor out test_diff_file_

Subject: [PATCH 3/8] test: factor out test_diff_file_

Date: Mon, 2 Aug 2021 12:09:17 -0300

To: notmuch@notmuchmail.org

Cc: David Bremner

From: David Bremner


A following commit will use this new function in a public test
function.
---
 test/test-lib.sh | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 10ee9b72..a8e57e51 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.
-- 
2.30.2
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: