git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org,  Stan Hu <stanhu@gmail.com>
Subject: Re: [PATCH 1/2] t9902: verify that completion does not print anything
Date: Thu, 11 Jan 2024 12:29:56 -0800	[thread overview]
Message-ID: <xmqqil3zfwaj.fsf@gitster.g> (raw)
In-Reply-To: <73406ca9c8f38ac2ad8f0e32d6d81f1566a6b4d1.1704969119.git.ps@pks.im> (Patrick Steinhardt's message of "Thu, 11 Jan 2024 11:41:54 +0100")

Patrick Steinhardt <ps@pks.im> writes:

> The Bash completion script must not print anything to either stdout or
> stderr. Instead, it is only expected to populate certain variables.
> Tighten our `test_completion ()` test helper to verify this requirement.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  t/t9902-completion.sh | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index aa9a614de3..78cb93bea7 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -87,9 +87,11 @@ test_completion ()
>  	else
>  		sed -e 's/Z$//' |sort >expected
>  	fi &&
> -	run_completion "$1" &&
> +	run_completion "$1" >"$TRASH_DIRECTORY"/output 2>&1 &&

OK, there is a call to test_completion after cd and this is a
reasonable way to make sure we write to a known location.

I would have done the "run_completion should be totally silent"
check immediately after this line, as they logically are more
related to each other than to the two lines that implement "the
'out' file when sorted must match the expectation we just prepared",
but that is not a huge deal.

The filename "output" is something that may tempt folks who add more
tests to this file to use for their own purpose; because we use it
only three times locally here, it might be safer to give it a bit
more specific name, e.g., "run-completion-output" or something.



>  	sort out >out_sorted &&
> -	test_cmp expected out_sorted
> +	test_cmp expected out_sorted &&
> +	test_must_be_empty "$TRASH_DIRECTORY"/output &&
> +	rm "$TRASH_DIRECTORY"/output
>  }
>  
>  # Test __gitcomp.


  reply	other threads:[~2024-01-11 20:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 10:41 [PATCH 0/2] completion: silence pseudo-ref existence check Patrick Steinhardt
2024-01-11 10:41 ` [PATCH 1/2] t9902: verify that completion does not print anything Patrick Steinhardt
2024-01-11 20:29   ` Junio C Hamano [this message]
2024-01-12 10:08   ` Johannes Schindelin
2024-01-12 10:50     ` Patrick Steinhardt
2024-01-12 13:12       ` Johannes Schindelin
2024-01-12 15:16         ` Jeff King
2024-01-12 18:17           ` Junio C Hamano
2024-01-15  9:02           ` Patrick Steinhardt
2024-01-11 10:41 ` [PATCH 2/2] completion: silence pseudoref existence check Patrick Steinhardt
2024-01-11 21:03   ` Junio C Hamano
2024-01-13 19:17   ` SZEDER Gábor
2024-01-15 10:35 ` [PATCH v2 0/5] completion: silence pseudo-ref " Patrick Steinhardt
2024-01-15 10:35   ` [PATCH v2 1/5] completion: discover repo path in `__git_pseudoref_exists ()` Patrick Steinhardt
2024-01-15 10:36   ` [PATCH v2 2/5] t9902: verify that completion does not print anything Patrick Steinhardt
2024-01-15 10:36   ` [PATCH v2 3/5] completion: improve existence check for pseudo-refs Patrick Steinhardt
2024-01-15 10:36   ` [PATCH v2 4/5] completion: silence pseudoref existence check Patrick Steinhardt
2024-01-15 10:36   ` [PATCH v2 5/5] completion: treat dangling symrefs as existing pseudorefs Patrick Steinhardt

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqil3zfwaj.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    --cc=stanhu@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).