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() {
82
82
kill " $GIT_DAEMON_PID "
83
83
wait " $GIT_DAEMON_PID " >&3 2>&4
84
84
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 $?
87
86
then
88
87
error " git daemon exited with status: $ret "
89
88
fi
Original file line number Diff line number Diff line change 11
11
12
12
test_expect_success ' sigchain works' '
13
13
{ 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
+ } &&
20
21
test_cmp expect actual
21
22
'
22
23
@@ -41,12 +42,12 @@ test_expect_success 'create blob' '
41
42
42
43
test_expect_success ! MINGW ' a constipated git dies with SIGPIPE' '
43
44
OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
44
- test "$OUT" -eq 141
45
+ test_match_signal 13 "$OUT"
45
46
'
46
47
47
48
test_expect_success ! MINGW ' a constipated git dies with SIGPIPE even if parent ignores it' '
48
49
OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
49
- test "$OUT" -eq 141
50
+ test_match_signal 13 "$OUT"
50
51
'
51
52
52
53
test_done
Original file line number Diff line number Diff line change @@ -612,7 +612,7 @@ test_must_fail () {
612
612
then
613
613
echo >&2 " test_must_fail: command succeeded: $* "
614
614
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
616
616
then
617
617
return 0
618
618
elif test $exit_code -gt 129 && test $exit_code -le 192
@@ -961,3 +961,18 @@ test_env () {
961
961
done
962
962
)
963
963
}
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