+ cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR}
+ notmuch new >/dev/null
+ cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail
+ fi
+}
+
+test_begin_subtest ()
+{
+ if [ -n "$inside_subtest" ]; then
+ exec 1>&6 2>&7 # Restore stdout and stderr
+ error "bug in test script: Missing test_expect_equal in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}"
+ fi
+ test_subtest_name="$1"
+ test_reset_state_
+ # Redirect test output to the previously prepared file descriptors
+ # 3 and 4 (see below)
+ if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
+ exec >&3 2>&4
+ inside_subtest=t
+}
+
+# Pass test if two arguments match
+#
+# Note: Unlike all other test_expect_* functions, this function does
+# not accept a test name. Instead, the caller should call
+# test_begin_subtest before calling this function in order to set the
+# name.
+test_expect_equal ()
+{
+ exec 1>&6 2>&7 # Restore stdout and stderr
+ inside_subtest=
+ test "$#" = 3 && { prereq=$1; shift; } || prereq=
+ test "$#" = 2 ||
+ error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
+
+ output="$1"
+ expected="$2"
+ if ! test_skip "$test_subtest_name"
+ then
+ if [ "$output" = "$expected" ]; then
+ test_ok_
+ else
+ testname=$this_test.$test_count
+ echo "$expected" > $testname.expected
+ echo "$output" > $testname.output
+ test_failure_ "$(diff -u $testname.expected $testname.output)"
+ fi
+ fi
+}
+
+# Like test_expect_equal, but takes two filenames.
+test_expect_equal_file ()
+{
+ exec 1>&6 2>&7 # Restore stdout and stderr
+ inside_subtest=
+ test "$#" = 3 && { prereq=$1; shift; } || prereq=
+ test "$#" = 2 ||
+ error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
+
+ file1="$1"
+ basename1=`basename "$file1"`
+ file2="$2"
+ basename2=`basename "$file2"`
+ if ! test_skip "$test_subtest_name"
+ then
+ if diff -q "$file1" "$file2" >/dev/null ; then
+ test_ok_
+ else
+ testname=$this_test.$test_count
+ cp "$file1" "$testname.$basename1"
+ cp "$file2" "$testname.$basename2"
+ test_failure_ "$(diff -u "$testname.$basename1" "$testname.$basename2")"
+ fi