]> git.notmuchmail.org Git - notmuch/commitdiff
test: check for empty/missing files in test_expect_equal_message_body
authorDavid Bremner <david@tethera.net>
Sun, 9 Apr 2023 14:26:24 +0000 (11:26 -0300)
committerDavid Bremner <david@tethera.net>
Fri, 21 Jul 2023 10:07:43 +0000 (07:07 -0300)
Messages can have empty bodies, but empty files are not messages.

test/test-lib.sh

index 1a6525dfa0e0d508b5289ad67f77dba8809e1cb9..f218fa03202a886b6144f4f957c2fe3104dece6e 100644 (file)
@@ -388,6 +388,14 @@ test_expect_equal_message_body () {
     test "$#" = 2 ||
        error "bug in the test script: not 2 parameters to test_expect_equal_file"
 
+    for file in "$1" "$2"; do
+       if [ ! -s "$file" ]; then
+           test_failure_ "Missing or zero length file: $file"
+           inside_subtest=
+           return 1
+       fi
+    done
+
     expected=$(sed '1,/^$/d' "$1")
     output=$(sed '1,/^$/d' "$2")
     test_expect_equal "$expected" "$output"