]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t4124: only mark git command with test_must_fail
authorDenton Liu <liu.denton@gmail.com>
Tue, 7 Jan 2020 04:53:13 +0000 (23:53 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Jan 2020 20:56:02 +0000 (12:56 -0800)
The test_must_fail function should only be used for git commands since
we should assume that external commands work sanely. Since apply_patch
wraps a sed and git invocation, rewrite it to accept an `!` argument
which would cause only the git command to be prefixed with
`test_must_fail`.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4124-apply-ws-rule.sh

index ff51e9e78914e4b9c7a801b4f88f3691b5f2844d..971a5a7512ac772f8b7e25a6a75bb4ac2ca43fd3 100755 (executable)
@@ -35,9 +35,15 @@ prepare_test_file () {
 }
 
 apply_patch () {
+       cmd_prefix= &&
+       if test "x$1" = 'x!'
+       then
+               cmd_prefix=test_must_fail &&
+               shift
+       fi &&
        >target &&
        sed -e "s|\([ab]\)/file|\1/target|" <patch |
-       git apply "$@"
+       $cmd_prefix git apply "$@"
 }
 
 test_fix () {
@@ -99,7 +105,7 @@ test_expect_success 'whitespace=warn, default rule' '
 
 test_expect_success 'whitespace=error-all, default rule' '
 
-       test_must_fail apply_patch --whitespace=error-all &&
+       apply_patch ! --whitespace=error-all &&
        test_must_be_empty target
 
 '