File tree Expand file tree Collapse file tree 3 files changed +26
-11
lines changed
Expand file tree Collapse file tree 3 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,7 @@ stop_git_daemon() {
8282 kill " $GIT_DAEMON_PID "
8383 wait " $GIT_DAEMON_PID " >&3 2>&4
8484 ret=$?
85- # expect exit with status 143 = 128+15 for signal TERM=15
86- if test $ret -ne 143
85+ if test_match_signal 15 $?
8786 then
8887 error " git daemon exited with status: $ret "
8988 fi
Original file line number Diff line number Diff line change 1111
1212test_expect_success ' sigchain works' '
1313 { test-sigchain >actual; ret=$?; } &&
14- case "$ret" in
15- 143) true ;; # POSIX w/ SIGTERM=15
16- 271) true ;; # ksh w/ SIGTERM=15
17- 3) true ;; # Windows
18- *) false ;;
19- esac &&
14+ {
15+ # Signal death by raise() on Windows acts like exit(3),
16+ # regardless of the signal number. So we must allow that
17+ # as well as the normal signal check.
18+ test_match_signal 15 "$ret" ||
19+ test "$ret" = 3
20+ } &&
2021 test_cmp expect actual
2122'
2223
@@ -41,12 +42,12 @@ test_expect_success 'create blob' '
4142
4243test_expect_success ! MINGW ' a constipated git dies with SIGPIPE' '
4344 OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
44- test "$OUT" -eq 141
45+ test_match_signal 13 "$OUT"
4546'
4647
4748test_expect_success ! MINGW ' a constipated git dies with SIGPIPE even if parent ignores it' '
4849 OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
49- test "$OUT" -eq 141
50+ test_match_signal 13 "$OUT"
5051'
5152
5253test_done
Original file line number Diff line number Diff line change @@ -612,7 +612,7 @@ test_must_fail () {
612612 then
613613 echo >&2 " test_must_fail: command succeeded: $* "
614614 return 1
615- elif test $exit_code -eq 141 && list_contains " $_test_ok " sigpipe
615+ elif test_match_signal 13 $exit_code && list_contains " $_test_ok " sigpipe
616616 then
617617 return 0
618618 elif test $exit_code -gt 129 && test $exit_code -le 192
@@ -961,3 +961,18 @@ test_env () {
961961 done
962962 )
963963}
964+
965+ # Returns true if the numeric exit code in "$2" represents the expected signal
966+ # in "$1". Signals should be given numerically.
967+ test_match_signal () {
968+ if test " $2 " = " $(( 128 + $1 )) "
969+ then
970+ # POSIX
971+ return 0
972+ elif test " $2 " = " $(( 256 + $1 )) "
973+ then
974+ # ksh
975+ return 0
976+ fi
977+ return 1
978+ }
You can’t perform that action at this time.
0 commit comments