]> git.ipfire.org Git - thirdparty/git.git/commit - t/test-lib-functions.sh
t: send verbose test-helper output to fd 4
authorJeff King <peff@peff.net>
Thu, 22 Feb 2018 06:48:37 +0000 (01:48 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Feb 2018 20:17:39 +0000 (12:17 -0800)
commit03aa3783f258737c02e0b3aba34bb4c9ed8c07dc
tree996b2cd0f10cd61574c06eee52b360bc19c34fe1
parente3a80781f5932f5fea12a49eb06f3ade4ed8945c
t: send verbose test-helper output to fd 4

Test helper functions like test_must_fail may produce
messages to stderr when they see a problem. When the tests
are run with "--verbose", this ends up on the test script's
stderr, and the user can read it.

But there's a problem. Some tests record stderr as part of
the test, like:

  test_must_fail git foo 2>output &&
  test_i18ngrep expected.message output

In this case the error text goes into "output". This makes
the --verbose output less useful (it also means we might
accidentally match it in the second, though in practice we
tend to produce these messages only on error, so we'd abort
the test when the first command fails).

Let's instead send this user-facing output directly to
descriptor 4, which always points to the original stderr (or
/dev/null in non-verbose mode). And it's already forbidden
to redirect descriptor 4, since we use it for BASH_XTRACEFD,
as explained in 9be795fbce (t5615: avoid re-using descriptor
4, 2017-12-08).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib-functions.sh