tests: add a special setup where prerequisites fail

As discussed in [1] there's a regression in the "pu" branch now
because a new test implicitly assumed that a previous test guarded by
a prerequisite had been run. Add a "GIT_TEST_FAIL_PREREQS" special
test setup where we'll skip (nearly) all tests guarded by
prerequisites, allowing us to easily emulate those platform where we
don't run these tests.

As noted in the documentation I'm adding I'm whitelisting the SYMLINKS
prerequisite for now. A lot of tests started failing if we lied about
not supporting symlinks. It's also unlikely that we'll have a failing
test due to a hard dependency on symlinks without that being the
obvious cause, so for now it's not worth the effort to make it work.

1. https://public-inbox.org/git/nycvar.QRO.7.76.6.1905131531000.44@tvgsbejvaqbjf.bet/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2019-05-13 20:32:42 +02:00
committed by Junio C Hamano
parent ab15ad1a3b
commit dfe1a17df9
7 changed files with 43 additions and 10 deletions

View File

@ -309,6 +309,26 @@ test_unset_prereq () {
}
test_set_prereq () {
if test -n "$GIT_TEST_FAIL_PREREQS"
then
case "$1" in
# The "!" case is handled below with
# test_unset_prereq()
!*)
;;
# (Temporary?) whitelist of things we can't easily
# pretend not to support
SYMLINKS)
;;
# Inspecting whether GIT_TEST_FAIL_PREREQS is on
# should be unaffected.
FAIL_PREREQS)
;;
*)
return
esac
fi
case "$1" in
!*)
test_unset_prereq "${1#!}"