All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 4/7] t: redirect stderr GIT_TRACE to descriptor 4
Date: Fri, 13 Mar 2015 00:50:56 -0400	[thread overview]
Message-ID: <20150313045056.GD18532@peff.net> (raw)
In-Reply-To: <20150313044101.GA18476@peff.net>

If you run a test script like:

  GIT_TRACE=1 ./t0061-run-command.sh

you may get test failures, because some tests capture and
check the stderr output from git commands (and with
GIT_TRACE set to 1, the trace output will be included
there).

When we see GIT_TRACE set like this, we print a warning to
the user. However, we can do even better than that by just
pointing it to descriptor 4, which all tests leave connected
to the test script's stderr. That's likely what the user
intended (and any scripts that do want to see GIT_TRACE
output will set GIT_TRACE themselves).

Not only does this avoid false negatives in the tests, but
it means the user will actually see trace output for git
calls that redirect their stderr (whereas before, it was
sometimes confusingly buried in a file).

Signed-off-by: Jeff King <peff@peff.net>
---
I only today figured out the GIT_TRACE=4 trick. Perhaps everybody else
did long ago, and I am just slow. :)

My first inclination was to mention it in the warning message below, but
I cannot see a downside to automatically redirecting it. Even outside of
test_expect_* we have the "4>&2" redirection, so we should hit even
badly written scripts which call git outside of that environment.

 t/test-lib.sh | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index f4ba3ff..7dd4b4d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -152,10 +152,7 @@ unset UNZIP
 
 case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
 1|2|true)
-	echo "* warning: Some tests will not work if GIT_TRACE" \
-		"is set as to trace on STDERR ! *"
-	echo "* warning: Please set GIT_TRACE to something" \
-		"other than 1, 2 or true ! *"
+	GIT_TRACE=4
 	;;
 esac
 
-- 
2.3.2.472.geadab3c

  parent reply	other threads:[~2015-03-13  4:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13  4:41 [PATCH 0/7] fix transfer.hiderefs with smart http Jeff King
2015-03-13  4:42 ` [PATCH 1/7] upload-pack: fix transfer.hiderefs over smart-http Jeff King
2015-03-13  6:21   ` Junio C Hamano
2015-03-13  4:42 ` [PATCH 2/7] upload-pack: do not check NULL return of lookup_unknown_object Jeff King
2015-03-13  4:48 ` [PATCH 3/7] t: translate SIGINT to an exit Jeff King
2015-03-13  4:50 ` Jeff King [this message]
2015-03-13  4:51 ` [PATCH 5/7] t: pass GIT_TRACE through Apache Jeff King
2015-03-13  4:53 ` [PATCH 6/7] t5541: move run_with_cmdline_limit to test-lib.sh Jeff King
2015-03-13  6:45   ` Eric Sunshine
2015-03-13  4:57 ` [PATCH 7/7] t5551: make EXPENSIVE test cheaper Jeff King
2015-03-13  4:59 ` [PATCH 0/7] fix transfer.hiderefs with smart http Jeff King
2015-03-13  5:21   ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150313045056.GD18532@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.