test: check for empty/missing files in test_expect_equal_message_body

Messages can have empty bodies, but empty files are not messages.
This commit is contained in:
David Bremner 2023-04-09 11:26:24 -03:00
parent dfa43a1921
commit f6fcdf12da

View file

@ -388,6 +388,14 @@ test_expect_equal_message_body () {
test "$#" = 2 || test "$#" = 2 ||
error "bug in the test script: not 2 parameters to test_expect_equal_file" 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") expected=$(sed '1,/^$/d' "$1")
output=$(sed '1,/^$/d' "$2") output=$(sed '1,/^$/d' "$2")
test_expect_equal "$expected" "$output" test_expect_equal "$expected" "$output"