diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-10-26 13:14:54 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-26 13:14:54 -0700 |
commit | f4db874d9adc3d974a085b1238aad0048e7f2674 (patch) | |
tree | 59fc5f6bb177ae3584510c4bd3bd3df604f8a9f5 /t/test-lib.sh | |
parent | bdcaebbedd54eeaf430ad1e4093a07922fe656d9 (diff) | |
parent | 614fe015212d057c0571885c42a29a995973107d (diff) | |
download | git-f4db874d9adc3d974a085b1238aad0048e7f2674.tar.gz |
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
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index 11562bde10..b859db61ac 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -54,12 +54,22 @@ case "$GIT_TEST_TEE_STARTED, $* " in done,*) # do not redirect again ;; -*' --tee '*|*' --va'*) +*' --tee '*|*' --va'*|*' --verbose-log '*) mkdir -p "$TEST_OUTPUT_DIRECTORY/test-results" BASE="$TEST_OUTPUT_DIRECTORY/test-results/$(basename "$0" .sh)" + + # Make this filename available to the sub-process in case it is using + # --verbose-log. + GIT_TEST_TEE_OUTPUT_FILE=$BASE.out + export GIT_TEST_TEE_OUTPUT_FILE + + # Truncate before calling "tee -a" to get rid of the results + # from any previous runs. + >"$GIT_TEST_TEE_OUTPUT_FILE" + (GIT_TEST_TEE_STARTED=done ${SHELL_PATH} "$0" "$@" 2>&1; - echo $? > $BASE.exit) | tee $BASE.out - test "$(cat $BASE.exit)" = 0 + echo $? >"$BASE.exit") | tee -a "$GIT_TEST_TEE_OUTPUT_FILE" + test "$(cat "$BASE.exit")" = 0 exit ;; esac @@ -246,6 +256,9 @@ do trace=t verbose=t shift ;; + --verbose-log) + verbose_log=t + shift ;; *) echo "error: unknown test option '$1'" >&2; exit 1 ;; esac @@ -308,6 +321,16 @@ say () { say_color info "$*" } +if test -n "$HARNESS_ACTIVE" +then + if test "$verbose" = t || test -n "$verbose_only" + then + printf 'Bail out! %s\n' \ + 'verbose mode forbidden under TAP harness; try --verbose-log' + exit 1 + fi +fi + test "${test_description}" != "" || error "Test script did not set test_description." @@ -319,7 +342,10 @@ fi exec 5>&1 exec 6<&0 -if test "$verbose" = "t" +if test "$verbose_log" = "t" +then + exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3 +elif test "$verbose" = "t" then exec 4>&2 3>&1 else |