t / t0005-signals.shon commit Merge branch 'jc/am-i-v-fix' into maint (28eec80)
   1#!/bin/sh
   2
   3test_description='signals work as we expect'
   4. ./test-lib.sh
   5
   6cat >expect <<EOF
   7three
   8two
   9one
  10EOF
  11
  12test_expect_success 'sigchain works' '
  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 &&
  20        test_cmp expect actual
  21'
  22
  23test_expect_success !MINGW 'signals are propagated using shell convention' '
  24        # we use exec here to avoid any sub-shell interpretation
  25        # of the exit code
  26        git config alias.sigterm "!exec test-sigchain" &&
  27        test_expect_code 143 git sigterm
  28'
  29
  30large_git () {
  31        for i in $(test_seq 1 100)
  32        do
  33                git diff --cached --binary || return
  34        done
  35}
  36
  37test_expect_success 'create blob' '
  38        test-genrandom foo 16384 >file &&
  39        git add file
  40'
  41
  42test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
  43        OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
  44        test "$OUT" -eq 141
  45'
  46
  47test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
  48        OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
  49        test "$OUT" -eq 141
  50'
  51
  52test_done