Re: [PATCH] test-lib-functions: simplify `test_file_not_empty` failure message
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 2, 2024, 18:08 UTC
- Message-ID
- <xmqq1q8sy09t.fsf@gitster.g>
- In-Reply-To
- <cf978790-4885-4103-946d-10f807048441@gmail.com>
Rubén Justo <rjusto@gmail.com> writes:
Show 18 quoted lines
> To improve the accuracy of the message, I wonder if it is worth doing
> ...
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index b5eaf7fdc1..5b5ee0dc1d 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -989,9 +989,10 @@ test_dir_is_empty () {
> # Check if the file exists and has a size greater than zero
> test_file_not_empty () {
> test "$#" = 2 && BUG "2 param"
> + test_path_is_file "$1" &&
> if ! test -s "$1"
> then
> - echo "'$1' is not a non-empty file."
> + echo "'$1' is empty but should not be"
> false
> fi
> }Simple and effective to remove the need to have to worry about the "missing" case. The "but should not be" part may still be subject to discussion, but I do not have a strong opinion there.