summaryrefslogtreecommitdiff
path: root/tests/tap-passthrough-exit.test
blob: aadeed6a82be024e8ba5f178d02b4a6a64674a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /bin/sh
# Copyright (C) 2011-2012 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# TAP support:
#  - non-success exit status of a test script is reported in the
#    log file
# See also related test 'tap-passthrough.test'.

am_parallel_tests=yes
. ./defs || Exit 1

cat > Makefile.am << 'END'
TEST_LOG_COMPILER = $(SHELL)
TESTS =
END

exit_statuses='1 2 77 99'

for e in $exit_statuses; do
  unindent > exit-$e.test <<END
    #!/bin/sh
    echo 1..1
    echo ok 1
    exit $e
END
  echo TESTS += exit-$e.test >> Makefile.am
done

. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"

st=0
$MAKE check || st=$?
for e in $exit_statuses; do cat exit-$e.log; done
cat test-suite.log
test $st -gt 0 || Exit 1

for e in $exit_statuses; do
  for log in exit-$e.log test-suite.log; do
    grep "^ERROR: exit-$e\\.test - exited with status $e$" $log
  done
done

env TEST_LOG_DRIVER_FLAGS='--ignore-exit' $MAKE -e check
$FGREP ".test - exited with status" *.log && Exit 1

: