diff --git a/t/README b/t/README index 7560db5c02..ed1ebb6a5c 100644 --- a/t/README +++ b/t/README @@ -65,6 +65,12 @@ appropriately before running "make". the test script when running under -i). Valgrind errors go to stderr, so you might want to pass the -v option, too. +--tee:: + In addition to printing the test output to the terminal, + write it to files named 't/test-results/$TEST_NAME.out'. + As the names depend on the tests' file names, it is safe to + run the tests with this option in parallel. + Skipping Tests -------------- diff --git a/t/test-lib.sh b/t/test-lib.sh index 5a58356c72..34f372c92f 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -3,6 +3,22 @@ # Copyright (c) 2005 Junio C Hamano # +# if --tee was passed, write the output not only to the terminal, but +# additionally to the file test-results/$BASENAME.out, too. +case "$GIT_TEST_TEE_STARTED, $* " in +done,*) + # do not redirect again + ;; +*' --tee '*) + mkdir -p test-results + BASE=test-results/$(basename "$0" .sh) + (GIT_TEST_TEE_STARTED=done ${SHELL-sh} "$0" "$@" 2>&1; + echo $? > $BASE.exit) | tee $BASE.out + test "$(cat $BASE.exit)" = 0 + exit + ;; +esac + # Keep the original TERM for say_color ORIGINAL_TERM=$TERM @@ -96,6 +112,8 @@ do shift ;; --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind) valgrind=t; shift ;; + --tee) + shift ;; # was handled already *) break ;; esac