3 # Copyright (c) 2005 Junio C Hamano
6 # For repeatability, reset the environment to known value.
14 unset COMMIT_AUTHOR_EMAIL
15 unset COMMIT_AUTHOR_NAME
16 unset GIT_ALTERNATE_OBJECT_DIRECTORIES
18 unset GIT_AUTHOR_EMAIL
20 unset GIT_COMMITTER_EMAIL
21 unset GIT_COMMITTER_NAME
24 unset GIT_EXTERNAL_DIFF
26 unset GIT_OBJECT_DIRECTORY
27 unset SHA1_FILE_DIRECTORIES
28 unset SHA1_FILE_DIRECTORY
30 # Each test should start with something like this, after copyright notices:
32 # test_description='Description of this test...
33 # This test checks if command xyzzy does the right thing...
46 test "${test_description}" != "" ||
47 error "Test script did not set test_description."
52 -d|--d|--de|--deb|--debu|--debug)
54 -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
56 -h|--h|--he|--hel|--help)
57 echo "$test_description"
59 -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
67 if test "$verbose" = "t"
71 exec 4>/dev/null 3>/dev/null
78 # You are not expected to call test_ok_ and test_failure_ directly, use
79 # the text_expect_* functions instead.
82 test_count=$(expr "$test_count" + 1)
83 say " ok $test_count: $@"
87 test_count=$(expr "$test_count" + 1)
88 test_failure=$(expr "$test_failure" + 1);
89 say "FAIL $test_count: $1"
91 echo "$@" | sed -e 's/^/ /'
92 test "$immediate" = "" || exit 1
97 test "$debug" = "" || eval "$1"
101 trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit
108 test_expect_failure () {
110 error "bug in the test script: not 2 parameters to test-expect-failure"
111 say >&3 "expecting failure: $2"
113 if [ "$?" = 0 -a "$eval_ret" != 0 ]
121 test_expect_success () {
123 error "bug in the test script: not 2 parameters to test-expect-success"
124 say >&3 "expecting success: $2"
126 if [ "$?" = 0 -a "$eval_ret" = 0 ]
135 case "$test_failure" in
138 # cd .. && rm -fr trash
139 # but that means we forbid any tests that use their own
140 # subdirectory from calling test_done without coming back
141 # to where they started from.
142 # The Makefile provided will clean this test area so
143 # we will leave things as they are.
145 say "passed all $test_count test(s)"
149 say "failed $test_failure among $test_count test(s)"
155 # Test the binaries we have just built. The tests are kept in
156 # t/ subdirectory and are run in trash subdirectory.
164 git-init-db 2>/dev/null || error "cannot run git-init-db"