Merge branch 'maint'
[platform/upstream/automake.git] / t / tap-bailout.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Basic TAP test protocol support:
18 #  - "Bail out!" magic
19
20 am_parallel_tests=yes
21 . ./defs || Exit 1
22
23 . "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
24
25 : > exp
26
27 #------------------------------------------------------------------
28
29 # Bailout without explanation.
30
31 cat > a.test <<END
32 1..4
33 ok 1
34 not ok 2
35 Bail out!
36 not ok 3
37 ok 4 # SKIP
38 END
39
40 cat >> exp <<END
41 PASS: a.test 1
42 FAIL: a.test 2
43 ERROR: a.test - Bail out!
44 END
45
46 # pass += 1, fail +=1, error += 1
47
48 #------------------------------------------------------------------
49
50 # Bailout with explanation.
51
52 cat > b.test <<END
53 1..7
54 ok 1 # SKIP
55 ok 2 # TODO
56 not ok 3 # TODO
57 Bail out! We're out of disk space.
58 ok 4
59 not ok 5
60 not ok 6 # TODO
61 ok 7 # TODO
62 END
63
64 cat >> exp <<END
65 SKIP: b.test 1 # SKIP
66 XPASS: b.test 2 # TODO
67 XFAIL: b.test 3 # TODO
68 ERROR: b.test - Bail out! We're out of disk space.
69 END
70
71 # skip += 1, xpass += 1, xfail += 1, error += 1
72
73 #------------------------------------------------------------------
74
75 # Bail out before the test plan.
76
77 cat > c.test <<END
78 ok 1
79 ok 2
80 Bail out! BOOOH!
81 1..2
82 END
83
84 cat >> exp <<END
85 PASS: c.test 1
86 PASS: c.test 2
87 ERROR: c.test - Bail out! BOOOH!
88 END
89
90 # pass += 2, error += 1
91
92 #------------------------------------------------------------------
93
94 # Bailout on the first line.
95
96 cat > d.test <<END
97 Bail out! mktemp -d: Permission denied
98 ok 1
99 END
100
101 echo 'ERROR: d.test - Bail out! mktemp -d: Permission denied' >> exp
102
103 # error += 1
104
105 #------------------------------------------------------------------
106
107 # TAP input comprised only of a bailout directive.
108
109 cat > e.test <<END
110 Bail out!
111 END
112
113 echo "ERROR: e.test - Bail out!" >> exp
114
115 # error += 1
116
117 #------------------------------------------------------------------
118
119 # Doing the sums above, we have:
120 test_counts='total=12 pass=3 fail=1 xpass=1 xfail=1 skip=1 error=5'
121
122 TESTS='a.test b.test c.test d.test e.test' $MAKE -e check >stdout \
123   && { cat stdout; Exit 1; }
124 cat stdout
125
126 count_test_results $test_counts
127
128 LC_ALL=C sort exp > t
129 mv -f t exp
130
131 # We need the sort below to account for parallel make usage.
132 grep ': [abcde]\.test' stdout | LC_ALL=C sort > got
133
134 cat exp
135 cat got
136 diff exp got
137
138 :