Merge branch 'bc/t3430-fixup'
[git.git] / t / t0005-signals.sh
blob4c214bd11c48859f0c4e64dbbe2d783e744eb1d1
1 #!/bin/sh
3 test_description='signals work as we expect'
4 . ./test-lib.sh
6 cat >expect <<EOF
7 three
8 two
9 one
10 EOF
12 test_expect_success 'sigchain works' '
13 { test-tool sigchain >actual; ret=$?; } &&
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 } &&
21 test_cmp expect actual
24 test_expect_success !MINGW 'signals are propagated using shell convention' '
25 # we use exec here to avoid any sub-shell interpretation
26 # of the exit code
27 git config alias.sigterm "!exec test-tool sigchain" &&
28 test_expect_code 143 git sigterm
31 large_git () {
32 for i in $(test_seq 1 100)
34 git diff --cached --binary || return
35 done
38 test_expect_success 'create blob' '
39 test-tool genrandom foo 16384 >file &&
40 git add file
43 test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
44 OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
45 test_match_signal 13 "$OUT"
48 test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
49 OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
50 test_match_signal 13 "$OUT"
53 test_done