@matheusbsbs / matheus-bagliano / commits / 37a63faae5
Fork 0

t4124: only mark git command with test_must_fail

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>

Denton Liu committed Jan 6, 2020 at 23:53 UTC 37a63faae58aee5cd2dd9806d2e98c9ad998a7e5
1 file changed +8 -2
t/t4124-apply-ws-rule.sh
+8 -2
@@ -35,9 +35,15 @@ prepare_test_file () {
35 }
36
37 apply_patch () {
38 + cmd_prefix= &&
39 + if test "x$1" = 'x!'
40 + then
41 + cmd_prefix=test_must_fail &&
42 + shift
43 + fi &&
44 >target &&
45 sed -e "s|\([ab]\)/file|\1/target|" <patch |
40 - git apply "$@"
46 + $cmd_prefix git apply "$@"
47 }
48
49 test_fix () {
@@ -99,7 +105,7 @@ test_expect_success 'whitespace=warn, default rule' '
105
106 test_expect_success 'whitespace=error-all, default rule' '
107
102 - test_must_fail apply_patch --whitespace=error-all &&
108 + apply_patch ! --whitespace=error-all &&
109 test_must_be_empty target
110
111 '