test-lib.sh: Add check for invalid use of 'skip_all' facility
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>
Sat, 1 Sep 2012 18:13:19 +0000 (19:13 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Sep 2012 02:32:31 +0000 (19:32 -0700)
The 'skip_all' facility cannot be used after one or more tests
have been executed using (for example) 'test_expect_success'.
To do so results in invalid TAP output, which leads to 'prove'
complaining of "Parse errors: No plan found in TAP output".

Add a check for such invalid usage and abort the test with an
error message to alert the test author.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh
index 007d7b20d8fe1be0f69e76215d51632c7df17205..7f4cb67c0fd53a6e92c6ed5bf9c2f23181365917 100644 (file)
@@ -383,6 +383,10 @@ test_done () {
        case "$test_failure" in
        0)
                # Maybe print SKIP message
        case "$test_failure" in
        0)
                # Maybe print SKIP message
+               if test -n "$skip_all" && test $test_count -gt 0
+               then
+                       error "Can't use skip_all after running some tests"
+               fi
                [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all"
 
                if test $test_external_has_tap -eq 0
                [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all"
 
                if test $test_external_has_tap -eq 0