[PATCH 2/4] test: check for empty/missing files in test_expect_equal_message_body

Subject: [PATCH 2/4] test: check for empty/missing files in test_expect_equal_message_body

Date: Wed, 4 Jan 2023 08:41:43 -0400

To: notmuch@notmuchmail.org

Cc:

From: David Bremner


Messages can have empty bodies, but empty files are not messages.
---
 test/test-lib.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index c2b8cd8d..a647790a 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -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 $?
+	fi
+    done
+
     expected=$(sed '1,/^$/d' "$1")
     output=$(sed '1,/^$/d' "$2")
     test_expect_equal "$expected" "$output"
-- 
2.39.0

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: