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

Re: [PATCH] t5534: split stdout and stderr redirection

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 6, 2020, 19:11 UTC
Message-ID
<xmqqft6r5fwb.fsf@gitster.c.googlers.com>
In-Reply-To
<20201006150818.15698-1-congdanhqx@gmail.com>
Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:
Show 18 quoted lines
> On atomic pushing failure with GnuPG, we expect a very specific output
> in stdout due to `--porcelain` switch.
>
> On such failure, we also write down some helpful hint into stderr
> in order to help user understand what happens and how to continue from
> those failures.
>
> On a lot of system, those hint (in stderr) will be flushed first,
> then those messages in stdout will be flushed. In such systems, the
> current test code is fine as is.
>
> However, we don't have such guarantee, (at least) there're some real
> systems that writes those stream interleaved. On such systems, we may
> see the stderr stream written in the middle of stdout stream.
>
> Let's split those stream redirection. By splitting those stream,
> the output stream will contain exactly what we want to compare,
> thus, saving us a "sed" invocation.
Makes sense.
> While we're at it, change the `test_i18ncmp` to `test_cmp` because we
> will never translate those messages (because of `--porcelain`).

Good thinking. It would make sure that we will catch when we accidentally mark messages meant for --porcelain with the gettext-poison tests.

Show 11 quoted lines
> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
> ---
>  Arguably, I would say it's OK to change the:
>  	
>  	test_i18ngrep ! "gpg failed to sign"
>
>  to:
>
>  	! grep "gpg failed to sign"
>
>  since the latter will be correct even if GIT_TEST_GETTEXT_POISON=true

Is it because we haven't managed to translate this particular message, or is it because we should never ever translate it perhaps because the message is meant for machine consumption? If the latter, yes, I agree with the reasoning, but I do not see a reason why this message should never be translated.

Show 29 quoted lines
>  t/t5534-push-signed.sh | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh
> index 7e928aff66..af0385fb89 100755
> --- a/t/t5534-push-signed.sh
> +++ b/t/t5534-push-signed.sh
> @@ -282,10 +282,9 @@ test_expect_success GPG 'failed atomic push does not execute GPG' '
>  	EOF
>  	test_must_fail env PATH="$TRASH_DIRECTORY:$PATH" git push \
>  			--signed --atomic --porcelain \
> -			dst noop ff noff >out 2>&1 &&
> +			dst noop ff noff >out 2>err &&
>  
> -	test_i18ngrep ! "gpg failed to sign" out &&
> -	sed -n -e "/^To dst/,$ p" out >actual &&
> +	test_i18ngrep ! "gpg failed to sign" err &&
>  	cat >expect <<-EOF &&
>  	To dst
>  	=	refs/heads/noop:refs/heads/noop	[up to date]
> @@ -293,7 +292,7 @@ test_expect_success GPG 'failed atomic push does not execute GPG' '
>  	!	refs/heads/noff:refs/heads/noff	[rejected] (non-fast-forward)
>  	Done
>  	EOF
> -	test_i18ncmp expect actual
> +	test_cmp expect out
>  '
>  
>  test_done
Previous: Đoàn Trần Công DanhNext: Đoàn Trần Công Danh
Message 2 of 4 in “t5534: split stdout and stderr redirection”
  1. t5534: split stdout and stderr redirectionĐoàn Trần Công Danh, Oct 6, 2020
  2. Junio C HamanoOct 6, 2020
  3. Đoàn Trần Công DanhOct 7, 2020
  4. Junio C HamanoOct 7, 2020

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.