Skip to content

Commit 5263e22

Browse files
peffgitster
authored andcommitted
t7006: simplify exit-code checks for sigpipe tests
Some tests in t7006 check for a SIGPIPE result by recording $? and comparing it with test_match_signal. Before the previous commit, the command was on the left-hand side of a pipe, and so we had to do some subshell trickery to extract it. But now that this is no longer the case, we can do things much more simply: just run the command directly, using braces to avoid wrecking the &&-chain, and then record $?. We could almost use test_expect_code here, but it doesn't know about test_match_signal. Likewise, for tests which expect success (i.e., not SIGPIPE), we can just put them in the &&-chain as usual. That even lets us get rid of the !MINGW check, since the expectation is the same on both sides. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f7991f0 commit 5263e22

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

t/t7006-pager.sh

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ test_expect_success TTY 'git returns SIGPIPE on early pager exit' '
677677
678678
if test_have_prereq !MINGW
679679
then
680-
OUT=$( ((test_terminal git log; echo $? 1>&3) >/dev/null) 3>&1 ) &&
680+
{ test_terminal git log >/dev/null; OUT=$?; } &&
681681
test_match_signal 13 "$OUT"
682682
else
683683
test_terminal git log
@@ -698,7 +698,7 @@ test_expect_success TTY 'git returns SIGPIPE on early pager non-zero exit' '
698698
699699
if test_have_prereq !MINGW
700700
then
701-
OUT=$( ((test_terminal git log; echo $? 1>&3) >/dev/null) 3>&1 ) &&
701+
{ test_terminal git log >/dev/null; OUT=$?; } &&
702702
test_match_signal 13 "$OUT"
703703
else
704704
test_terminal git log
@@ -717,13 +717,7 @@ test_expect_success TTY 'git discards pager non-zero exit without SIGPIPE' '
717717
export GIT_TRACE2 &&
718718
test_when_finished "unset GIT_TRACE2" &&
719719
720-
if test_have_prereq !MINGW
721-
then
722-
OUT=$( ((test_terminal git log; echo $? 1>&3) >/dev/null) 3>&1 ) &&
723-
test "$OUT" -eq 0
724-
else
725-
test_terminal git log
726-
fi &&
720+
test_terminal git log &&
727721
728722
grep child_exit trace.normal >child-exits &&
729723
test_line_count = 1 child-exits &&
@@ -738,13 +732,7 @@ test_expect_success TTY 'git skips paging nonexisting command' '
738732
export GIT_TRACE2 &&
739733
test_when_finished "unset GIT_TRACE2" &&
740734
741-
if test_have_prereq !MINGW
742-
then
743-
OUT=$( ((test_terminal git log; echo $? 1>&3) >/dev/null) 3>&1 ) &&
744-
test "$OUT" -eq 0
745-
else
746-
test_terminal git log
747-
fi &&
735+
test_terminal git log &&
748736
749737
grep child_exit trace.normal >child-exits &&
750738
test_line_count = 1 child-exits &&
@@ -760,7 +748,7 @@ test_expect_success TTY 'git returns SIGPIPE on propagated signals from pager' '
760748
761749
if test_have_prereq !MINGW
762750
then
763-
OUT=$( ((test_terminal git log; echo $? 1>&3) >/dev/null) 3>&1 ) &&
751+
{ test_terminal git log >/dev/null; OUT=$?; } &&
764752
test_match_signal 13 "$OUT"
765753
else
766754
test_terminal git log

0 commit comments

Comments
 (0)