Skip to content

Commit f4db874

Browse files
committed
Merge branch 'jk/tap-verbose-fix'
The Travis CI configuration we ship ran the tests with --verbose option but this risks non-TAP output that happens to be "ok" to be misinterpreted as TAP signalling a test that passed. This resulted in unnecessary failure. This has been corrected by introducing a new mode to run our tests in the test harness to send the verbose output separately to the log file. * jk/tap-verbose-fix: test-lib: bail out when "-v" used under "prove" travis: use --verbose-log test option test-lib: add --verbose-log option test-lib: handle TEST_OUTPUT_DIRECTORY with spaces
2 parents bdcaebb + 614fe01 commit f4db874

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ env:
3131
- LINUX_GIT_LFS_VERSION="1.2.0"
3232
- DEFAULT_TEST_TARGET=prove
3333
- GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
34-
- GIT_TEST_OPTS="--verbose --tee"
34+
- GIT_TEST_OPTS="--verbose-log"
3535
- GIT_TEST_HTTPD=true
3636
- GIT_TEST_CLONE_2GB=YesPlease
3737
# t9810 occasionally fails on Travis CI OS X

t/README

+6
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ appropriately before running "make".
153153
As the names depend on the tests' file names, it is safe to
154154
run the tests with this option in parallel.
155155

156+
--verbose-log::
157+
Write verbose output to the same logfile as `--tee`, but do
158+
_not_ write it to stdout. Unlike `--tee --verbose`, this option
159+
is safe to use when stdout is being consumed by a TAP parser
160+
like `prove`. Implies `--tee` and `--verbose`.
161+
156162
--with-dashes::
157163
By default tests are run without dashed forms of
158164
commands (like git-commit) in the PATH (it only uses

t/test-lib.sh

+30-4
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,22 @@ case "$GIT_TEST_TEE_STARTED, $* " in
5454
done,*)
5555
# do not redirect again
5656
;;
57-
*' --tee '*|*' --va'*)
57+
*' --tee '*|*' --va'*|*' --verbose-log '*)
5858
mkdir -p "$TEST_OUTPUT_DIRECTORY/test-results"
5959
BASE="$TEST_OUTPUT_DIRECTORY/test-results/$(basename "$0" .sh)"
60+
61+
# Make this filename available to the sub-process in case it is using
62+
# --verbose-log.
63+
GIT_TEST_TEE_OUTPUT_FILE=$BASE.out
64+
export GIT_TEST_TEE_OUTPUT_FILE
65+
66+
# Truncate before calling "tee -a" to get rid of the results
67+
# from any previous runs.
68+
>"$GIT_TEST_TEE_OUTPUT_FILE"
69+
6070
(GIT_TEST_TEE_STARTED=done ${SHELL_PATH} "$0" "$@" 2>&1;
61-
echo $? > $BASE.exit) | tee $BASE.out
62-
test "$(cat $BASE.exit)" = 0
71+
echo $? >"$BASE.exit") | tee -a "$GIT_TEST_TEE_OUTPUT_FILE"
72+
test "$(cat "$BASE.exit")" = 0
6373
exit
6474
;;
6575
esac
@@ -246,6 +256,9 @@ do
246256
trace=t
247257
verbose=t
248258
shift ;;
259+
--verbose-log)
260+
verbose_log=t
261+
shift ;;
249262
*)
250263
echo "error: unknown test option '$1'" >&2; exit 1 ;;
251264
esac
@@ -308,6 +321,16 @@ say () {
308321
say_color info "$*"
309322
}
310323

324+
if test -n "$HARNESS_ACTIVE"
325+
then
326+
if test "$verbose" = t || test -n "$verbose_only"
327+
then
328+
printf 'Bail out! %s\n' \
329+
'verbose mode forbidden under TAP harness; try --verbose-log'
330+
exit 1
331+
fi
332+
fi
333+
311334
test "${test_description}" != "" ||
312335
error "Test script did not set test_description."
313336

@@ -319,7 +342,10 @@ fi
319342

320343
exec 5>&1
321344
exec 6<&0
322-
if test "$verbose" = "t"
345+
if test "$verbose_log" = "t"
346+
then
347+
exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3
348+
elif test "$verbose" = "t"
323349
then
324350
exec 4>&2 3>&1
325351
else

0 commit comments

Comments
 (0)