All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <ericsunshine@charter.net>
Cc: git@vger.kernel.org,  Aryan Gupta <garyan447@gmail.com>,
	 Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH] test-lib-functions: simplify `test_file_not_empty` failure message
Date: Fri, 01 Mar 2024 14:11:21 -0800	[thread overview]
Message-ID: <xmqqsf194n7a.fsf@gitster.g> (raw)
In-Reply-To: <20240301204922.40304-1-ericsunshine@charter.net> (Eric Sunshine's message of "Fri, 1 Mar 2024 15:49:22 -0500")

Eric Sunshine <ericsunshine@charter.net> writes:

> Note: Technically, the revised message is slightly less accurate since
> the function asserts both that the file exists and that it is non-empty,
> but the new message talks only about the emptiness of the file, not
> whether it exists.
>
> A more accurate message might be "'foo' is empty but
> should not be (or doesn't exist)", but that's unnecessarily long-winded
> and adds little information that the test author couldn't discover by
> noticing the file's absence.

Besides, that is way too confusing.  "<foo> is empty or it does not
exist" I may understand, but with your construct, I wouldn't be able
to tell how I am supposed to interpret the "(or doesn't exist)"
part.

> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index b5eaf7fdc1..9e97b324c5 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -991,7 +991,7 @@ test_file_not_empty () {
>  	test "$#" = 2 && BUG "2 param"
>  	if ! test -s "$1"
>  	then
> -		echo "'$1' is not a non-empty file."
> +		echo "'$1' is empty but should not be"

The "adds little information" version may be

		echo "'$1' is either missing or empty, but should not be"

And avoiding "X is Y, but should  be ~Y" construct, perhaps

		echo "'$1' should be a file with non-empty contents"

would work better?  I dunno.

  reply	other threads:[~2024-03-01 22:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 20:49 [PATCH] test-lib-functions: simplify `test_file_not_empty` failure message Eric Sunshine
2024-03-01 22:11 ` Junio C Hamano [this message]
2024-03-01 22:59   ` Eric Sunshine
2024-03-02  7:07     ` Dirk Gouders
2024-03-02 17:44       ` Junio C Hamano
2024-03-03  6:42         ` Dirk Gouders
2024-03-02 16:38 ` Rubén Justo
2024-03-02 18:08   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsf194n7a.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=ericsunshine@charter.net \
    --cc=garyan447@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.