diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2019-06-21 13:18:12 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-06-21 19:42:49 +0300 |
commit | c740039921528198efa21f9cf6ccb849e74164c4 (patch) | |
tree | d3005f9d8b3520a699d7ae598dc370f18b892c44 /t/test-lib.sh | |
parent | 3b072c577ba594a9fb4ae9426409f1caadafcb08 (diff) |
tests: make GIT_TEST_FAIL_PREREQS a boolean
Change the GIT_TEST_FAIL_PREREQS variable from being "non-empty?" to
being a more standard boolean variable. I recently added the variable
in dfe1a17df9 ("tests: add a special setup where prerequisites fail",
2019-05-13), having to add another "non-empty?" special-case is what
prompted me to write the "git env--helper" utility being used here.
Converting this one is a bit tricky since we use it so early and
frequently in the guts of the test code itself, so let's set a
GIT_TEST_FAIL_PREREQS_INTERNAL which can be tested with the old "test
-n" for the purposes of the shell code, and change the user-exposed
and documented GIT_TEST_FAIL_PREREQS variable to a boolean.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index ed5d69dfe5..1af4e50653 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1389,6 +1389,25 @@ yes () { done } +# The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and +# thus needs to be set up really early, and set an internal variable +# for convenience so the hot test_set_prereq() codepath doesn't need +# to call "git env--helper". Only do that work if needed by seeing if +# GIT_TEST_FAIL_PREREQS is set at all. +GIT_TEST_FAIL_PREREQS_INTERNAL= +if test -n "$GIT_TEST_FAIL_PREREQS" +then + if git env--helper --type=bool --default=0 --exit-code GIT_TEST_FAIL_PREREQS + then + GIT_TEST_FAIL_PREREQS_INTERNAL=true + test_set_prereq FAIL_PREREQS + fi +else + test_lazy_prereq FAIL_PREREQS ' + git env--helper --type=bool --default=0 --exit-code GIT_TEST_FAIL_PREREQS + ' +fi + # Fix some commands on Windows uname_s=$(uname -s) case $uname_s in @@ -1605,7 +1624,3 @@ test_lazy_prereq SHA1 ' test_lazy_prereq REBASE_P ' test -z "$GIT_TEST_SKIP_REBASE_P" ' - -test_lazy_prereq FAIL_PREREQS ' - test -n "$GIT_TEST_FAIL_PREREQS" -' |