]> git.ipfire.org Git - thirdparty/git.git/commit - t/test-lib.sh
test-lib: bail out when "-v" used under "prove"
authorJeff King <peff@peff.net>
Sat, 22 Oct 2016 04:45:06 +0000 (00:45 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Oct 2016 16:26:00 +0000 (09:26 -0700)
commit614fe015212d057c0571885c42a29a995973107d
tree5a6c27b827b02327eb9e396ccdae678b9752135b
parent041c72de109075d630f77bc2ad225f6339f33c9a
test-lib: bail out when "-v" used under "prove"

When there is a TAP harness consuming the output of our test
scripts, the "--verbose" breaks the output by mingling
test command output with TAP. Because the TAP::Harness
module used by "prove" is fairly lenient, this _usually_
works, but it violates the spec, and things get very
confusing if the commands happen to output a line that looks
like TAP (e.g., the word "ok" on its own line).

Let's detect this situation and complain. Just calling
error() isn't great, though; prove will tell us that the
script failed, but the message doesn't make it through to
the user. Instead, we can use the special TAP signal "Bail
out!". This not only shows the message to the user, but
instructs the harness to stop running the tests entirely.
This is exactly what we want here, as the problem is in the
command-line options, and every test script would produce
the same error.

The result looks like this (the first "Bailout called" line
is in red if prove uses color on your terminal):

 $ make GIT_TEST_OPTS='--verbose --tee'
 rm -f -r 'test-results'
 *** prove ***
 Bailout called.  Further testing stopped:  verbose mode forbidden under TAP harness; try --verbose-log
 FAILED--Further testing stopped: verbose mode forbidden under TAP harness; try --verbose-log
 Makefile:39: recipe for target 'prove' failed
 make: *** [prove] Error 255

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