]>
Commit | Line | Data |
---|---|---|
4a16d072 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='signals work as we expect' | |
c150064d ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
4a16d072 JK |
6 | . ./test-lib.sh |
7 | ||
8 | cat >expect <<EOF | |
9 | three | |
10 | two | |
11 | one | |
12 | EOF | |
13 | ||
14 | test_expect_success 'sigchain works' ' | |
e154a6f3 | 15 | { test-tool sigchain >actual; ret=$?; } && |
9b67c994 JK |
16 | { |
17 | # Signal death by raise() on Windows acts like exit(3), | |
18 | # regardless of the signal number. So we must allow that | |
19 | # as well as the normal signal check. | |
20 | test_match_signal 15 "$ret" || | |
21 | test "$ret" = 3 | |
22 | } && | |
4a16d072 JK |
23 | test_cmp expect actual |
24 | ' | |
25 | ||
04422c74 | 26 | test_expect_success !MINGW 'signals are propagated using shell convention' ' |
e828908a JK |
27 | # we use exec here to avoid any sub-shell interpretation |
28 | # of the exit code | |
e154a6f3 | 29 | git config alias.sigterm "!exec test-tool sigchain" && |
e828908a JK |
30 | test_expect_code 143 git sigterm |
31 | ' | |
32 | ||
7559a1be PR |
33 | large_git () { |
34 | for i in $(test_seq 1 100) | |
35 | do | |
36 | git diff --cached --binary || return | |
37 | done | |
38 | } | |
39 | ||
40 | test_expect_success 'create blob' ' | |
c680668d | 41 | test-tool genrandom foo 16384 >file && |
7559a1be PR |
42 | git add file |
43 | ' | |
44 | ||
4e6d207c | 45 | test_expect_success !MINGW 'a constipated git dies with SIGPIPE' ' |
635ce72f | 46 | OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) && |
6f5f9d74 | 47 | test_match_signal 13 "$OUT" |
7559a1be PR |
48 | ' |
49 | ||
4e6d207c | 50 | test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' ' |
c576868e | 51 | OUT=$( ((trap "" PIPE && large_git; echo $? 1>&3) | :) 3>&1 ) && |
6f5f9d74 | 52 | test_match_signal 13 "$OUT" |
7559a1be PR |
53 | ' |
54 | ||
4a16d072 | 55 | test_done |