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

[PATCH 1/2] test-lib: turn off "-x" tracing during chain-lint check

From
Jeff King <peff@peff.net>
Date
Aug 6, 2015, 05:31 UTC
Message-ID
<20150806053146.GA32703@sigill.intra.peff.net>
In-Reply-To
<20150806052940.GA32445@sigill.intra.peff.net>
Now that GIT_TEST_CHAIN_LINT is on by default, running:
    ./t0000-basic.sh -x --verbose-only=1
starts with:
    expecting success:
            find .git/objects -type f -print >should-be-empty &&
            test_line_count = 0 should-be-empty
    + exit 117
    error: last command exited with $?=117
    + find .git/objects -type f -print
    + test_line_count = 0 should-be-empty
    + test 3 != 3
    + wc -l
    + test 0 = 0
    ok 1 - .git/objects should be empty after git init in an empty repo

This is confusing, as the "exit 117" line and the error line (which is printed in red, no less!) are not part of the test at all, but are rather in the separate chain-lint test_eval. Let's unset the "trace" variable when eval-ing the chain lint check, which avoids this.

Note that we cannot just do a one-shot variable like:
    trace= test_eval ...

as the behavior of one-shot variables for function calls is not portable.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/test-lib.sh | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index cea6cda..374bfcb 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -571,12 +571,17 @@ test_run_ () {
 	expecting_failure=$2
 
 	if test "${GIT_TEST_CHAIN_LINT:-1}" != 0; then
+		# turn off tracing for this test-eval, as it simply creates
+		# confusing noise in the "-x" output
+		trace_tmp=$trace
+		trace=
 		# 117 is magic because it is unlikely to match the exit
 		# code of other programs
 		test_eval_ "(exit 117) && $1"
 		if test "$?" != 117; then
 			error "bug in the test script: broken &&-chain: $1"
 		fi
+		trace=$trace_tmp
 	fi
 
 	setup_malloc_check
-- 
2.5.0.148.g63828c1
Previous: Jeff KingNext: Jeff King
Message 7 of 10 in “What's cooking in git.git”
  1. Junio C HamanoAug 5, 2015
  2. David TurnerAug 5, 2015
  3. Junio C HamanoAug 5, 2015
  4. Junio C HamanoAug 7, 2015
  5. Jeff KingAug 6, 2015
  6. 0/2 ./t5512-*.sh -x complaintsJeff King, Aug 6, 2015
  7. 1/2 test-lib: turn off "-x" tracing during chain-lint checkJeff King, Aug 6, 2015
  8. 2/2 test-lib: disable trace when test is not verboseJeff King, Aug 6, 2015
  9. Junio C HamanoAug 7, 2015
  10. Johannes SchindelinAug 6, 2015

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.