Skip to content

Commit c7018be

Browse files
committed
test: allow skipping the remainder
Because TAP output does not like to see the remainder of the test getting skipped after running one or more tests, bf4b721 ("test-lib.sh: Add check for invalid use of 'skip_all' facility", 2012-09-01) made sure that test_done errors out when this happens. Instead, loosen the check so that we only pretend that the rest of the test script did not exist in such a case. We'd lose a bit of information (i.e. TAP does not notice that we are skipping some tests), but not very much (i.e. TAP wasn't told how many tests are skipped anyway). This will allow inclusion of lib-httpd.sh in the middle of a test, which will skip the remainder of the test scripts when tests that involve web server are declined with GIT_TEST_HTTPD=false, for example. Acked-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b06d364 commit c7018be

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

t/test-lib.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -745,20 +745,25 @@ test_done () {
745745
fi
746746
case "$test_failure" in
747747
0)
748-
# Maybe print SKIP message
749-
if test -n "$skip_all" && test $test_count -gt 0
750-
then
751-
error "Can't use skip_all after running some tests"
752-
fi
753-
test -z "$skip_all" || skip_all=" # SKIP $skip_all"
754-
755748
if test $test_external_has_tap -eq 0
756749
then
757750
if test $test_remaining -gt 0
758751
then
759752
say_color pass "# passed all $msg"
760753
fi
761-
say "1..$test_count$skip_all"
754+
755+
# Maybe print SKIP message
756+
test -z "$skip_all" || skip_all="# SKIP $skip_all"
757+
case "$test_count" in
758+
0)
759+
say "1..$test_count${skip_all:+ $skip_all}"
760+
;;
761+
*)
762+
test -z "$skip_all" ||
763+
say_color warn "$skip_all"
764+
say "1..$test_count"
765+
;;
766+
esac
762767
fi
763768

764769
test -d "$remove_trash" &&

0 commit comments

Comments
 (0)