git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.

Previous: Rubén Justo
Message 8 of 8 in “test-lib-functions: simplify `test_file_not_empty` failure message”
  1. test-lib-functions: simplify `test_file_not_empty` failure messageEric Sunshine, Mar 1, 2024
  2. Junio C HamanoMar 1, 2024
  3. Eric SunshineMar 1, 2024
  4. Dirk GoudersMar 2, 2024
  5. Junio C HamanoMar 2, 2024
  6. Dirk GoudersMar 3, 2024
  7. Rubén JustoMar 2, 2024
  8. Junio C HamanoMar 2, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.