Skip to content

Commit e6a6ddc

Browse files
Thomas Rastgitster
authored andcommitted
test-lib: refactor $GIT_SKIP_TESTS matching
It's already used twice, and we will have more of the same kind of matching in a minute. Helped-by: Johannes Sixt <[email protected]> Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a57397b commit e6a6ddc

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

t/test-lib.sh

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,20 @@ test_debug () {
328328
test "$debug" = "" || eval "$1"
329329
}
330330

331+
match_pattern_list () {
332+
arg="$1"
333+
shift
334+
test -z "$*" && return 1
335+
for pattern_
336+
do
337+
case "$arg" in
338+
$pattern_)
339+
return 0
340+
esac
341+
done
342+
return 1
343+
}
344+
331345
test_eval_ () {
332346
# This is a separate function because some tests use
333347
# "return" to end a test_expect_success block early.
@@ -358,14 +372,10 @@ test_run_ () {
358372
test_skip () {
359373
test_count=$(($test_count+1))
360374
to_skip=
361-
for skp in $GIT_SKIP_TESTS
362-
do
363-
case $this_test.$test_count in
364-
$skp)
365-
to_skip=t
366-
break
367-
esac
368-
done
375+
if match_pattern_list $this_test.$test_count $GIT_SKIP_TESTS
376+
then
377+
to_skip=t
378+
fi
369379
if test -z "$to_skip" && test -n "$test_prereq" &&
370380
! test_have_prereq "$test_prereq"
371381
then
@@ -630,15 +640,12 @@ cd -P "$TRASH_DIRECTORY" || exit 1
630640

631641
this_test=${0##*/}
632642
this_test=${this_test%%-*}
633-
for skp in $GIT_SKIP_TESTS
634-
do
635-
case "$this_test" in
636-
$skp)
637-
say_color info >&3 "skipping test $this_test altogether"
638-
skip_all="skip all tests in $this_test"
639-
test_done
640-
esac
641-
done
643+
if match_pattern_list "$this_test" $GIT_SKIP_TESTS
644+
then
645+
say_color info >&3 "skipping test $this_test altogether"
646+
skip_all="skip all tests in $this_test"
647+
test_done
648+
fi
642649

643650
# Provide an implementation of the 'yes' utility
644651
yes () {

0 commit comments

Comments
 (0)