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

Re: [PATCH 2/2] t3404: be resilient against running with the -x flag

From
Jeff King <peff@peff.net>
Date
May 10, 2016, 20:58 UTC
Message-ID
<20160510205800.GC19958@sigill.intra.peff.net>
In-Reply-To
<xmqqshxpofqh.fsf@gitster.mtv.corp.google.com>
On Tue, May 10, 2016 at 12:49:42PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> I wonder if we can fix "-x" instead so that we do not have to
> butcher tests like this patch does.  It was quite clear what it
> expected to see before this patch, and it is sad that the workaround
> makes less readable (and relies on the real output we are looking
> for never begins with '+').

I don't think there is a scalable, portable way to do so. "-x" output is going to stderr, and is inherited by any functions or subshells. So either we have to ask "-x" output to go somewhere else, or we have to turn it off inside the functions and subshells. The latter requires tweaking each site, which isn't scalable. And there is no way to do the former in a portable way (AFAIK).

That being said, bash supports BASH_XTRACEFD, so maybe something like this:

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

would help Dscho's case (and people on other shells aren't helped, but
they are not hurt either).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 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.