3 # Simple shell command language test library.
5 # Tests must follow the basic form:
7 # begin_test "the thing"
15 # When a test fails its stdout and stderr are shown.
17 # Note that tests must `set -e' within the subshell block or failed assertions
18 # will not cause the test to fail and the result may be misreported.
20 # Copyright (c) 2011-13 by Ryan Tomayko <http://tomayko.com>
28 # keep track of num tests and failures
32 # this runs at process exit
36 if [ $failures -gt 0 ]; then
43 # create the trash dir
49 # if the file exists, assume another process started it, and will clean it up
51 if [ -s $LFS_URL_FILE ]; then
55 failures=$(( failures + 1 ))
60 GITSERVER=$(cat "$LFS_URL_FILE")
61 SSLGITSERVER=$(cat "$LFS_SSL_URL_FILE")
62 CLIENTCERTGITSERVER=$(cat "$LFS_CLIENT_CERT_URL_FILE")
65 # Mark the beginning of a test. A subshell should immediately follow this
69 [ -n "$test_description" ] && end_test $test_status
72 tests=$(( tests + 1 ))
78 trace="$TRASHDIR/trace"
80 exec 1>"$out" 2>"$err"
82 # enabling GIT_TRACE can cause Windows git to stall, esp with fd 5
83 # other fd numbers like 8/9 don't stall but still don't work, so disable
84 if [ $IS_WINDOWS -eq 0 ]; then
89 # reset global git config
91 rm -rf "$TRASHDIR/home"
93 cp "$TESTHOME/.gitconfig" "$HOME/.gitconfig"
95 # do not let Git use a different configuration file
99 # allow the subshell to exit non-zero without exiting this process
103 # Mark the end of a test.
105 test_status="${1:-$?}"
108 # close fd 5 (GIT_TRACE)
111 if [ "$test_status" -eq 0 ]; then
112 printf "test: %-60s OK\n" "$test_description ..."
114 failures=$(( failures + 1 ))
115 printf "test: %-60s FAILED\n" "$test_description ..."
118 sed 's/^/ /' <"$TRASHDIR/out"
120 grep -v -e '^\+ end_test' -e '^+ set +x' <"$TRASHDIR/err" |
122 if [ $IS_WINDOWS -eq 0 ]; then
123 echo "-- git trace --"
124 sed 's/^/ /' <"$TRASHDIR/trace"
129 unset test_description