Re: [PATCH v4 2/5] test: check for empty/missing files in test_expect_equal_message_body

Subject: Re: [PATCH v4 2/5] test: check for empty/missing files in test_expect_equal_message_body

Date: Tue, 11 Jul 2023 18:14:45 +0300

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


On Sun, Jul 09 2023, David Bremner wrote:

> 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 1a6525df..b5aa94dd 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=

the above line will set $? = 0

sh -c 'false; x=; echo $?' echoes 0

> +	    return $?
> +	fi
> +    done
> +
>      expected=$(sed '1,/^$/d' "$1")
>      output=$(sed '1,/^$/d' "$2")
>      test_expect_equal "$expected" "$output"
> -- 
> 2.40.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: