test-lib: allow selecting tests by substring/glob with --run
Many of our test scripts have several "setup" tests. It's a lot easier to say ./t0050-filesystem.sh --run=setup,9 in order to run all the setup tests as well as test #9, than it is to track down what all the setup tests are and enter all their numbers in the list. Also, I often find myself wanting to run just one or a couple tests from the test file, but I don't know the numbering of any of the tests -- to get it I either have to first run the whole test file (or start counting by hand or figure out some other clever but non-obvious tricks). It's really convenient to be able to just look at the test description(s) and then run ./t6416-recursive-corner-cases.sh --run=symlink or ./t6402-merge-rename.sh --run='setup,unnecessary update' Add such an ability to test selection which relies on merely matching against the test description. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
d4a392452e
commit
f21ac368f1
@ -769,15 +769,17 @@ match_pattern_list () {
|
||||
}
|
||||
|
||||
match_test_selector_list () {
|
||||
operation="$1"
|
||||
shift
|
||||
title="$1"
|
||||
shift
|
||||
arg="$1"
|
||||
shift
|
||||
test -z "$1" && return 0
|
||||
|
||||
# Both commas and whitespace are accepted as separators.
|
||||
# Commas are accepted as separators.
|
||||
OLDIFS=$IFS
|
||||
IFS=' ,'
|
||||
IFS=','
|
||||
set -- $1
|
||||
IFS=$OLDIFS
|
||||
|
||||
@ -805,13 +807,13 @@ match_test_selector_list () {
|
||||
*-*)
|
||||
if expr "z${selector%%-*}" : "z[0-9]*[^0-9]" >/dev/null
|
||||
then
|
||||
echo "error: $title: invalid non-numeric in range" \
|
||||
echo "error: $operation: invalid non-numeric in range" \
|
||||
"start: '$orig_selector'" >&2
|
||||
exit 1
|
||||
fi
|
||||
if expr "z${selector#*-}" : "z[0-9]*[^0-9]" >/dev/null
|
||||
then
|
||||
echo "error: $title: invalid non-numeric in range" \
|
||||
echo "error: $operation: invalid non-numeric in range" \
|
||||
"end: '$orig_selector'" >&2
|
||||
exit 1
|
||||
fi
|
||||
@ -819,9 +821,11 @@ match_test_selector_list () {
|
||||
*)
|
||||
if expr "z$selector" : "z[0-9]*[^0-9]" >/dev/null
|
||||
then
|
||||
echo "error: $title: invalid non-numeric in test" \
|
||||
"selector: '$orig_selector'" >&2
|
||||
exit 1
|
||||
case "$title" in *${selector}*)
|
||||
include=$positive
|
||||
;;
|
||||
esac
|
||||
continue
|
||||
fi
|
||||
esac
|
||||
|
||||
@ -1031,7 +1035,7 @@ test_skip () {
|
||||
skipped_reason="GIT_SKIP_TESTS"
|
||||
fi
|
||||
if test -z "$to_skip" && test -n "$run_list" &&
|
||||
! match_test_selector_list '--run' $test_count "$run_list"
|
||||
! match_test_selector_list '--run' "$1" $test_count "$run_list"
|
||||
then
|
||||
to_skip=t
|
||||
skipped_reason="--run"
|
||||
|
Reference in New Issue
Block a user