3 # if --tee was passed, write the output not only to the terminal, but
4 # additionally to the file test-results/$BASENAME.out, too.
5 case "$SVN2SVN_TEST_TEE_STARTED, $* " in
7 # do not redirect again
11 BASE
=test-results/$(basename "$0" .sh)
12 (SVN2SVN_TEST_TEE_STARTED
=done ${SHELL-sh} "$0" "$@" 2>&1;
13 echo $?
> $BASE.
exit) | tee $BASE.out
14 test "$(cat $BASE.exit)" = 0
19 # Check if terminal supports color
20 [ "x$TERM" != "xdumb" ] && (
22 tput bold
>/dev
/null
2>&1 &&
23 tput setaf
1 >/dev
/null
2>&1 &&
24 tput sgr0
>/dev
/null
2>&1
32 -d|--d|--de|--deb|--debu|--debug)
34 -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
36 -h|--h|--he|--hel|--help)
38 -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
40 -q|--q|--qu|--qui|--quie|--quiet)
45 shift ;; # was handled already
47 echo "error: unknown test option '$1'" exit 1 ;;
51 # Define print-helper tags
52 if test -n "$color"; then
56 error
) tput bold
; tput setaf
1;; # bold red
57 skip
) tput bold
; tput setaf
2;; # bold green
58 pass
) tput setaf
2;; # green
59 info
) tput setaf
3;; # brown
60 *) test -n "$quiet" && return;;
70 test -z "$1" && test -n "$quiet" && return
77 say_color error
"error: $*"
86 # Make sure parent test was setup correctly
87 test "${test_description}" != "" ||
88 error
"Test script did not set test_description."
93 echo "$test_description"
99 if test "$verbose" = "t"
103 exec 4>/dev
/null
3>/dev
/null
112 test_external_has_tap
=0
116 if test -n "$SVN2SVN_EXIT_OK"
120 echo >&5 "FATAL: Unexpected exit with code $code"
128 .
"${TEST_DIRECTORY:-.}"/test-lib-functions.sh
130 # You are not expected to call test_ok_ and test_failure_ directly, use
131 # the text_expect_* functions instead.
134 test_success
=$(($test_success + 1))
135 say_color
"" "ok $test_count - $@"
139 test_failure
=$(($test_failure + 1))
140 say_color error
"not ok - $test_count $1"
142 echo "$@" | sed -e 's/^/# /'
143 test "$immediate" = "" || { SVN2SVN_EXIT_OK
=t
; exit 1; }
146 test_known_broken_ok_
() {
147 test_fixed
=$(($test_fixed+1))
148 say_color
"" "ok $test_count - $@ # TODO known breakage"
151 test_known_broken_failure_
() {
152 test_broken
=$(($test_broken+1))
153 say_color skip
"not ok $test_count - $@ # TODO known breakage"
157 test "$debug" = "" || eval "$1"
161 # This is a separate function because some tests use
162 # "return" to end a test_expect_success block early.
163 eval </dev
/null
>&3 2>&4 "$*"
172 if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
174 test_eval_
"$test_cleanup"
176 if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
183 test_count
=$(($test_count+1))
185 for skp
in $SVN2SVN_SKIP_TESTS
187 case $this_test.
$test_count in
193 if test -z "$to_skip" && test -n "$test_prereq" &&
194 ! test_have_prereq
"$test_prereq"
201 if test "$missing_prereq" != "$test_prereq"
203 of_prereq
=" of $test_prereq"
206 say_color skip
>&3 "skipping test: $@"
207 say_color skip
"ok $test_count # skip $1 (missing $missing_prereq${of_prereq})"
217 test_at_end_hook_
() {
224 if test -z "$HARNESS_ACTIVE"; then
225 test_results_dir
="$TEST_OUTPUT_DIRECTORY/test-results"
226 mkdir -p "$test_results_dir"
227 test_results_path
="$test_results_dir/${0%.sh}-$$.counts"
229 cat >>"$test_results_path" <<-EOF
231 success $test_success
239 if test "$test_fixed" != 0
241 say_color pass
"# fixed $test_fixed known breakage(s)"
243 if test "$test_broken" != 0
245 say_color error
"# still have $test_broken known breakage(s)"
246 msg
="remaining $(($test_count-$test_broken)) test(s)"
248 msg
="$test_count test(s)"
250 case "$test_failure" in
252 # Maybe print SKIP message
253 [ -z "$skip_all" ] || skip_all
=" # SKIP $skip_all"
255 if test $test_external_has_tap -eq 0; then
256 say_color pass
"# passed all $msg"
257 say
"1..$test_count$skip_all"
260 test -d "$remove_trash" &&
261 cd "$(dirname "$remove_trash")" &&
262 rm -rf "$(basename "$remove_trash")"
269 if test $test_external_has_tap -eq 0; then
270 say_color error
"# failed $test_failure among $msg"
279 # Test the binaries we have just built. The tests are kept in
280 # t/ subdirectory and are run in 'trash directory' subdirectory.
281 if test -z "$TEST_DIRECTORY"
283 # We allow tests to override this, in case they want to run tests
284 # outside of t/, e.g. for running tests on the test library
286 TEST_DIRECTORY
=$(pwd)
288 if test -z "$TEST_OUTPUT_DIRECTORY"
290 # Similarly, override this to store the test-results subdir
292 TEST_OUTPUT_DIRECTORY
=$TEST_DIRECTORY