Skip to content

Commit

Permalink
t: do not hide Git's exit code in tests using 'nul_to_q'
Browse files Browse the repository at this point in the history
Git should not be on the left-hand side of a pipe, because it hides the exit
code, and we want to make sure git does not fail.

Fix all invocations of 'nul_to_q' (defined in /t/test-lib-functions.sh) using
this pattern. There is one more occurrence of the pattern in t9010-svn-fe.sh
which is too evolved to change it easily.

All remaining test code that does not adhere to the pattern can be found with
the following command:
git grep -E 'git.*[^|]\|($|[^|])'

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Lars Schneider authored and Junio C Hamano committed Feb 17, 2016
1 parent 7548842 commit a0578e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions t/t1300-repo-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -957,13 +957,15 @@ Qsection.sub=section.val4
Qsection.sub=section.val5Q
EOF
test_expect_success '--null --list' '
git config --null --list | nul_to_q >result &&
git config --null --list >result.raw &&
nul_to_q <result.raw >result &&
echo >>result &&
test_cmp expect result
'

test_expect_success '--null --get-regexp' '
git config --null --get-regexp "val[0-9]" | nul_to_q >result &&
git config --null --get-regexp "val[0-9]" >result.raw &&
nul_to_q <result.raw >result &&
echo >>result &&
test_cmp expect result
'
Expand Down
3 changes: 2 additions & 1 deletion t/t7008-grep-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ test_expect_success 'grep respects not-binary diff attribute' '
test_cmp expect actual &&
echo "b diff" >.gitattributes &&
echo "b:binQary" >expect &&
git grep bin b | nul_to_q >actual &&
git grep bin b >actual.raw &&
nul_to_q <actual.raw >actual &&
test_cmp expect actual
'

Expand Down

0 comments on commit a0578e0

Please sign in to comment.