On 04/27/2015 12:04 AM, Junio C Hamano wrote: > "brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes: > >> While I was adding tests, I noticed that we had a broken test due to the >> use of single quotes within a test, which resulted in the test always >> being skipped. > > Good eyes. While fixing the test is necessary, we should also be > able to improve the test framework to prevent such mistakes at the > same time. > > ok 38 # skip > git clone "[myhost:123]:src" ssh-bracket-clone && > expect_ssh myhost -p (missing bracketed hostnames are still > ssh) > > The test scripts are expected to take either 3 or 4 parameters, and > the extra parameter when it takes 4 is the comma separated list of > prerequisites. "bracketed hostnames are still ssh" does not look > like prerequisites at all to us humans, and the framework should > also be able to notice that and barf, I would think. > > Perhaps something like this? > > t/test-lib-functions.sh | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh > index 0698ce7..0e4f2a6 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 > Thanks for fixing my bugs :-) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html