]> git.ipfire.org Git - thirdparty/git.git/commit - t/test-lib-functions.sh
test-lib-functions: restrict test_must_fail usage
authorDenton Liu <liu.denton@gmail.com>
Tue, 7 Jul 2020 06:04:38 +0000 (02:04 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Jul 2020 22:47:16 +0000 (15:47 -0700)
commit6a67c759489e1025665adf78326e9e0d0981bab5
tree8f87455edc9839cab463ecc083bbbbd11f48781d
parent41feac6f74719922bcc0bd44683518a6d6a8a943
test-lib-functions: restrict test_must_fail usage

In previous commits, we removed the usage of test_must_fail() for most
commands except for a set of pre-approved commands. Since that's done,
only allow test_must_fail() to run those pre-approved commands.

Obviously, we should allow `git`.

We allow `__git*` as some completion functions return an error code that
comes from a git invocation. It's good to avoid using test_must_fail
unnecessarily but it wouldn't hurt to err on the side of caution when
we're potentially wrapping a git command (like in these cases).

We also allow `test-tool` and `test-svn-fe` because these are helper
commands that are written by us and we want to catch their failure.

Finally, we allow `test_terminal` because `test_terminal` just wraps
around git commands. Also, we cannot rewrite
`test_must_fail test_terminal` as `test_terminal test_must_fail` because
test_must_fail() is a shell function and as a result, it cannot be
invoked from the test-terminal Perl script.

We opted to explicitly list the above tools instead of using a catch-all
such as `test[-_]*` because we want to be as restrictive as possible so
that in the future, someone would not accidentally introduce an
unrelated usage of test_must_fail() on an "unapproved" command.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0000-basic.sh
t/test-lib-functions.sh