summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-04-26 22:18:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-04-28 22:20:33 (GMT)
commitd93d5d51e3d104f4466f2081dd45b9670dc28744 (patch)
treec6fec7bfd6421a18ad4eff04ff23d015e782ca20 /t/test-lib-functions.sh
parent8c2ea51254b41810edf4ee1ac8b2272a784b15df (diff)
downloadgit-d93d5d51e3d104f4466f2081dd45b9670dc28744.zip
git-d93d5d51e3d104f4466f2081dd45b9670dc28744.tar.gz
git-d93d5d51e3d104f4466f2081dd45b9670dc28744.tar.bz2
test: validate prerequistes syntax
Brian Carson noticed that a test piece in t5601 had a pair of single quotes in the body, which made it into 4 parameter call to test_expect_success, as if its test title were a prerequisite. As the prerequisites have a specific syntax (i.e. comma separated tokens spelled in capital letters, possibly prefixed with ! for negation), validate them to catch such a mistake in the future. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 0698ce7..2c47d82 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -348,11 +348,18 @@ test_declared_prereq () {
return 1
}
+test_verify_prereq () {
+ test -z "$test_prereq" ||
+ expr >/dev/null "$test_prereq" : '[A-Z0-9_,!]*$' ||
+ error "bug in the test script: '$test_prereq' does not look like a prereq"
+}
+
test_expect_failure () {
test_start_
test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
test "$#" = 2 ||
error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
+ test_verify_prereq
export test_prereq
if ! test_skip "$@"
then
@@ -372,6 +379,7 @@ test_expect_success () {
test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
test "$#" = 2 ||
error "bug in the test script: not 2 or 3 parameters to test-expect-success"
+ test_verify_prereq
export test_prereq
if ! test_skip "$@"
then
@@ -400,6 +408,7 @@ test_external () {
error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
descr="$1"
shift
+ test_verify_prereq
export test_prereq
if ! test_skip "$descr" "$@"
then