diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-12-05 21:52:48 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-12-05 21:52:48 +0100 |
commit | e0f9ec90278ec989ac7840a69f42a414f0db23f5 (patch) | |
tree | da196a1d49be6527919614e004f0090a9ffef590 /t/t0000-basic.sh | |
parent | Merge branch 'mh/clear-topo-walk-upon-reset' (diff) | |
parent | t5608-clone-2gb.sh: turn GIT_TEST_CLONE_2GB into a bool (diff) | |
download | git-e0f9ec90278ec989ac7840a69f42a414f0db23f5.tar.xz git-e0f9ec90278ec989ac7840a69f42a414f0db23f5.zip |
Merge branch 'sg/test-bool-env'
Recently we have declared that GIT_TEST_* variables take the
usual boolean values (it used to be that some used "non-empty
means true" and taking GIT_TEST_VAR=YesPlease as true); make
sure we notice and fail when non-bool strings are given to
these variables.
* sg/test-bool-env:
t5608-clone-2gb.sh: turn GIT_TEST_CLONE_2GB into a bool
tests: add 'test_bool_env' to catch non-bool GIT_TEST_* values
Diffstat (limited to 't/t0000-basic.sh')
-rwxr-xr-x | t/t0000-basic.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index a5195a8dc4..8a81a249d0 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -917,6 +917,40 @@ test_expect_success 'test_oid can look up data for SHA-256' ' test "$hexsz" -eq 64 ' +test_expect_success 'test_bool_env' ' + ( + sane_unset envvar && + + test_bool_env envvar true && + ! test_bool_env envvar false && + + envvar= && + export envvar && + ! test_bool_env envvar true && + ! test_bool_env envvar false && + + envvar=true && + test_bool_env envvar true && + test_bool_env envvar false && + + envvar=false && + ! test_bool_env envvar true && + ! test_bool_env envvar false && + + envvar=invalid && + # When encountering an invalid bool value, test_bool_env + # prints its error message to the original stderr of the + # test script, hence the redirection of fd 7, and aborts + # with "exit 1", hence the subshell. + ! ( test_bool_env envvar true ) 7>err && + grep "error: test_bool_env requires bool values" err && + + envvar=true && + ! ( test_bool_env envvar invalid ) 7>err && + grep "error: test_bool_env requires bool values" err + ) +' + ################################################################ # Basics of the basics |