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

Re: [PATCH] tests: drop use of 'tee' that hides exit status

From
Rubén Justo <rjusto@gmail.com>
Date
Aug 9, 2024, 00:37 UTC
Message-ID
<93e6fdd3-4a15-4cc5-929a-aa5e79f44e1c@gmail.com>
In-Reply-To
<xmqq4j7uhfvm.fsf@gitster.g>
On Thu, Aug 08, 2024 at 02:19:25PM -0700, Junio C Hamano wrote:
Show 6 quoted lines
> A few tests have "| tee output" downstream of a git command, and
> then inspect the contents of the file.  The net effect is that we
> use an extra process, and hide the exit status from the upstream git
> command.
> 
> In none of these tests, I do not see a reason why we want to hide a

This double negative caught my attention. The message is understandable; perhaps "In none of these tests I see ..." would have been clearer.

Show 8 quoted lines
> possible failure from these git commands.  Replace the use of tee
> with a plain simple redirection.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  t/t1001-read-tree-m-2way.sh | 2 +-
>  t/t5523-push-upstream.sh    | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
A simple search only points to these two files:
   $ git grep '\s*git.*|\s*tee' "t/t[0-9]*.sh"
   t/t1001-read-tree-m-2way.sh:400:        git ls-files --stage | tee >treeMcheck.out &&
   t/t5523-push-upstream.sh:127:   test_terminal git push --quiet --no-progress upstream main 2>&1 | tee output &&
   t/t5523-push-upstream.sh:134:   test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&
And the following three changes are in line with the result:
Show 35 quoted lines
> 
> diff --git c/t/t1001-read-tree-m-2way.sh w/t/t1001-read-tree-m-2way.sh
> index 88c524f655..48a1550371 100755
> --- c/t/t1001-read-tree-m-2way.sh
> +++ w/t/t1001-read-tree-m-2way.sh
> @@ -397,7 +397,7 @@ test_expect_success 'a/b vs a, plus c/d case setup.' '
>  
>  test_expect_success 'a/b vs a, plus c/d case test.' '
>  	read_tree_u_must_succeed -u -m "$treeH" "$treeM" &&
> -	git ls-files --stage | tee >treeMcheck.out &&
> +	git ls-files --stage >treeMcheck.out &&
>  	test_cmp treeM.out treeMcheck.out
>  '
>  
> diff --git c/t/t5523-push-upstream.sh w/t/t5523-push-upstream.sh
> index 1f859ade16..4ad36a31e1 100755
> --- c/t/t5523-push-upstream.sh
> +++ w/t/t5523-push-upstream.sh
> @@ -124,14 +124,14 @@ test_expect_success TTY 'push --no-progress suppresses progress' '
>  test_expect_success TTY 'quiet push' '
>  	ensure_fresh_upstream &&
>  
> -	test_terminal git push --quiet --no-progress upstream main 2>&1 | tee output &&
> +	test_terminal git push --quiet --no-progress upstream main >output 2>&1 &&
>  	test_must_be_empty output
>  '
>  
>  test_expect_success TTY 'quiet push -u' '
>  	ensure_fresh_upstream &&
>  
> -	test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output &&
> +	test_terminal git push --quiet -u --no-progress upstream main >output 2>&1 &&
>  	test_must_be_empty output
>  '
>  
Looks good.
Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 6 in “tests: drop use of 'tee' that hides exit status”
  1. tests: drop use of 'tee' that hides exit statusJunio C Hamano, Aug 8, 2024
  2. Rubén JustoAug 9, 2024
  3. Junio C HamanoAug 9, 2024
  4. Johannes SchindelinAug 13, 2024
  5. Jeff KingAug 13, 2024
  6. Junio C HamanoAug 13, 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.