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

Re: [PATCH] test-lib: set BASH_XTRACEFD automatically

From
Junio C Hamano <gitster@pobox.com>
Date
May 10, 2016, 22:06 UTC
Message-ID
<xmqqd1otmut8.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160510213218.GA27028@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 19 quoted lines
> The patch itself is a trivial-looking one-liner, but there
> are a few subtleties worth mentioning:
>
>   - the variable is _not_ exported; the "set -x" is local to
>     our process, and so the tracefd should match
>
>   - this line has to come after we do the redirection for fd
>     4, as bash will otherwise complain during the variable
>     assignment
>
>   - likewise, we cannot ever unset this variable, as it
>     would close descriptor 4
>
>   - setting it once here is sufficient to cover both the
>     regular "-x" case (which implies "--verbose"), as well
>     as "--verbose-only=1". This works because the latter
>     flips "set -x" off and on for particular tests (if it
>     didn't, we would get tracing for all tests, as going to
>     descriptor 4 effectively circumvents the verbose flag).

Thanks. Some of them may deserve to be next to the one-liner to prevent people from making changes that tickle them?

Show 35 quoted lines
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  t/README      | 6 +++---
>  t/test-lib.sh | 1 +
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/t/README b/t/README
> index 1dc908e..76a0daa 100644
> --- a/t/README
> +++ b/t/README
> @@ -84,9 +84,9 @@ appropriately before running "make".
>  
>  -x::
>  	Turn on shell tracing (i.e., `set -x`) during the tests
> -	themselves. Implies `--verbose`. Note that this can cause
> -	failures in some tests which redirect and test the
> -	output of shell functions. Use with caution.
> +	themselves. Implies `--verbose`. Note that in non-bash shells,
> +	this can cause failures in some tests which redirect and test
> +	the output of shell functions. Use with caution.
>  
>  -d::
>  --debug::
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 286c5f3..482ec11 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -321,6 +321,7 @@ then
>  else
>  	exec 4>/dev/null 3>/dev/null
>  fi
> +BASH_XTRACEFD=4
>  
>  test_failure=0
>  test_count=0
Previous: Jeff KingNext: Jeff King
Message 8 of 17 in “Work on t3404 in preparation for rebase--helper”
  1. 0/2 Work on t3404 in preparation for rebase--helperJohannes Schindelin, May 10, 2016
  2. 1/2 t3404: fix typoJohannes Schindelin, May 10, 2016
  3. 2/2 t3404: be resilient against running with the -x flagJohannes Schindelin, May 10, 2016
  4. Junio C HamanoMay 10, 2016
  5. Jeff KingMay 10, 2016
  6. Junio C HamanoMay 10, 2016
  7. test-lib: set BASH_XTRACEFD automaticallyJeff King, May 10, 2016
  8. Junio C HamanoMay 10, 2016
  9. test-lib: set BASH_XTRACEFD automaticallyJeff King, May 11, 2016
  10. Johannes SchindelinMay 12, 2016
  11. 0/2 Work on t3404 in preparation for rebase--helperJohannes Schindelin, May 12, 2016
  12. 1/2 t3404: fix typoJohannes Schindelin, May 12, 2016
  13. 2/2 test-lib: set BASH_XTRACEFD automaticallyJohannes Schindelin, May 12, 2016
  14. Junio C HamanoMay 12, 2016
  15. Johannes SchindelinMay 13, 2016
  16. Junio C HamanoMay 13, 2016
  17. Johannes SchindelinMay 16, 2016

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.