X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Ftest-lib.sh;fp=test%2Ftest-lib.sh;h=dc4962f560b6dc48dcf0de22fd7f25ac3903e832;hp=6f4bb47fb88c681d015f0b879f3c7b148c34f70f;hb=474a7f8e6506ed5c027a5f8e4c11261cda5a17dc;hpb=78045301e7dd3caf82d5efc241d10b351be33b28 diff --git a/test/test-lib.sh b/test/test-lib.sh index 6f4bb47f..dc4962f5 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -434,6 +434,26 @@ test_expect_equal_file () { test_diff_file_ "$1" "$2" } +# Like test_expect_equal, but takes two filenames. Fails if either is empty +test_expect_equal_file_nonempty () { + exec 1>&6 2>&7 # Restore stdout and stderr + if [ -z "$inside_subtest" ]; then + error "bug in the test script: test_expect_equal_file_nonempty without test_begin_subtest" + fi + inside_subtest= + test "$#" = 2 || + error "bug in the test script: not 2 parameters to test_expect_equal_file_nonempty" + + for file in "$1" "$2"; do + if [ ! -s "$file" ]; then + test_failure_ "Missing or zero length file: $file" + return $? + fi + done + + 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.