Skip to content

Commit 614fe01

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 041c72d commit 614fe01

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

t/test-lib.sh

+10
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,16 @@ say () {
317317
say_color info "$*"
318318
}
319319

320+
if test -n "$HARNESS_ACTIVE"
321+
then
322+
if test "$verbose" = t || test -n "$verbose_only"
323+
then
324+
printf 'Bail out! %s\n' \
325+
'verbose mode forbidden under TAP harness; try --verbose-log'
326+
exit 1
327+
fi
328+
fi
329+
320330
test "${test_description}" != "" ||
321331
error "Test script did not set test_description."
322332

0 commit comments

Comments
 (0)