@matheusbsbs / matheus-bagliano / commits / 04ece59399
Fork 0

GIT_SKIP_TESTS: allow users to omit tests that are known to break

In some environments, certain tests have no way of succeeding due to platform limitation, such as lack of 'unzip' program, or filesystem that do not allow arbitrary sequence of non-NUL bytes as pathnames. You should be able to say something like $ cd t $ GIT_SKIP_TESTS=t9200.8 t9200-git-cvsexport-commit.sh and even: $ GIT_SKIP_TESTS='t[0-4]??? t91?? t9200.8' make test to omit such tests. The value of the environment variable is a SP separated list of patterns that tells which tests to skip, and either can match the "t[0-9]{4}" part to skip the whole test, or t[0-9]{4} followed by ".$number" to say which particular test to skip. Note that some tests in the existing test suite rely on previous test item, so you cannot arbitrarily disable one and expect the remainder of test to check what the test originally was intended to check. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 28, 2006 at 17:58 UTC 04ece59399ba159d82cadec8d39f8ce13c12d569
1 file changed +70 -18
t/test-lib.sh
+70 -18
@@ -125,16 +125,43 @@ test_run_ () {
125 return 0
126 }
127
128 +test_skip () {
129 + this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
130 + this_test="$this_test.$(expr "$test_count" + 1)"
131 + to_skip=
132 + for skp in $GIT_SKIP_TESTS
133 + do
134 + case "$this_test" in
135 + $skp)
136 + to_skip=t
137 + esac
138 + done
139 + case "$to_skip" in
140 + t)
141 + say >&3 "skipping test: $@"
142 + test_count=$(expr "$test_count" + 1)
143 + say "skip $test_count: $1"
144 + : true
145 + ;;
146 + *)
147 + false
148 + ;;
149 + esac
150 +}
151 +
152 test_expect_failure () {
153 test "$#" = 2 ||
154 error "bug in the test script: not 2 parameters to test-expect-failure"
131 - say >&3 "expecting failure: $2"
132 - test_run_ "$2"
133 - if [ "$?" = 0 -a "$eval_ret" != 0 -a "$eval_ret" -lt 129 ]
155 + if ! test_skip "$@"
156 then
135 - test_ok_ "$1"
136 - else
137 - test_failure_ "$@"
157 + say >&3 "expecting failure: $2"
158 + test_run_ "$2"
159 + if [ "$?" = 0 -a "$eval_ret" != 0 -a "$eval_ret" -lt 129 ]
160 + then
161 + test_ok_ "$1"
162 + else
163 + test_failure_ "$@"
164 + fi
165 fi
166 echo >&3 ""
167 }
@@ -142,13 +169,16 @@ test_expect_failure () {
169 test_expect_success () {
170 test "$#" = 2 ||
171 error "bug in the test script: not 2 parameters to test-expect-success"
145 - say >&3 "expecting success: $2"
146 - test_run_ "$2"
147 - if [ "$?" = 0 -a "$eval_ret" = 0 ]
172 + if ! test_skip "$@"
173 then
149 - test_ok_ "$1"
150 - else
151 - test_failure_ "$@"
174 + say >&3 "expecting success: $2"
175 + test_run_ "$2"
176 + if [ "$?" = 0 -a "$eval_ret" = 0 ]
177 + then
178 + test_ok_ "$1"
179 + else
180 + test_failure_ "$@"
181 + fi
182 fi
183 echo >&3 ""
184 }
@@ -156,13 +186,16 @@ test_expect_success () {
186 test_expect_code () {
187 test "$#" = 3 ||
188 error "bug in the test script: not 3 parameters to test-expect-code"
159 - say >&3 "expecting exit code $1: $3"
160 - test_run_ "$3"
161 - if [ "$?" = 0 -a "$eval_ret" = "$1" ]
189 + if ! test_skip "$@"
190 then
163 - test_ok_ "$2"
164 - else
165 - test_failure_ "$@"
191 + say >&3 "expecting exit code $1: $3"
192 + test_run_ "$3"
193 + if [ "$?" = 0 -a "$eval_ret" = "$1" ]
194 + then
195 + test_ok_ "$2"
196 + else
197 + test_failure_ "$@"
198 + fi
199 fi
200 echo >&3 ""
201 }
@@ -223,3 +256,22 @@ test=trash
256 rm -fr "$test"
257 test_create_repo $test
258 cd "$test"
259 +
260 +this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
261 +for skp in $GIT_SKIP_TESTS
262 +do
263 + to_skip=
264 + for skp in $GIT_SKIP_TESTS
265 + do
266 + case "$this_test" in
267 + $skp)
268 + to_skip=t
269 + esac
270 + done
271 + case "$to_skip" in
272 + t)
273 + say >&3 "skipping test $this_test altogether"
274 + say "skip all tests in $this_test"
275 + test_done
276 + esac
277 +done