am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / tap-bailout.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 . test-init.sh
21
22 . tap-setup.sh
23
24 : > exp
25
26 #------------------------------------------------------------------
27
28 # Bailout without explanation.
29
30 cat > a.test <<END
31 1..4
32 ok 1
33 not ok 2
34 Bail out!
35 not ok 3
36 ok 4 # SKIP
37 END
38
39 cat >> exp <<END
40 PASS: a.test 1
41 FAIL: a.test 2
42 ERROR: a.test - Bail out!
43 END
44
45 # pass += 1, fail +=1, error += 1
46
47 #------------------------------------------------------------------
48
49 # Bailout with explanation.
50
51 cat > b.test <<END
52 1..7
53 ok 1 # SKIP
54 ok 2 # TODO
55 not ok 3 # TODO
56 Bail out! We're out of disk space.
57 ok 4
58 not ok 5
59 not ok 6 # TODO
60 ok 7 # TODO
61 END
62
63 cat >> exp <<END
64 SKIP: b.test 1 # SKIP
65 XPASS: b.test 2 # TODO
66 XFAIL: b.test 3 # TODO
67 ERROR: b.test - Bail out! We're out of disk space.
68 END
69
70 # skip += 1, xpass += 1, xfail += 1, error += 1
71
72 #------------------------------------------------------------------
73
74 # Bail out before the test plan.
75
76 cat > c.test <<END
77 ok 1
78 ok 2
79 Bail out! BOOOH!
80 1..2
81 END
82
83 cat >> exp <<END
84 PASS: c.test 1
85 PASS: c.test 2
86 ERROR: c.test - Bail out! BOOOH!
87 END
88
89 # pass += 2, error += 1
90
91 #------------------------------------------------------------------
92
93 # Bailout on the first line.
94
95 cat > d.test <<END
96 Bail out! mktemp -d: Permission denied
97 ok 1
98 END
99
100 echo 'ERROR: d.test - Bail out! mktemp -d: Permission denied' >> exp
101
102 # error += 1
103
104 #------------------------------------------------------------------
105
106 # TAP input comprised only of a bailout directive.
107
108 cat > e.test <<END
109 Bail out!
110 END
111
112 echo "ERROR: e.test - Bail out!" >> exp
113
114 # error += 1
115
116 #------------------------------------------------------------------
117
118 # Doing the sums above, we have:
119 test_counts='total=12 pass=3 fail=1 xpass=1 xfail=1 skip=1 error=5'
120
121 run_make -O -e FAIL TESTS='a.test b.test c.test d.test e.test' check
122 count_test_results $test_counts
123
124 LC_ALL=C sort exp > t
125 mv -f t exp
126
127 # We need the sort below to account for parallel make usage.
128 grep ': [abcde]\.test' stdout | LC_ALL=C sort > got
129
130 cat exp
131 cat got
132 diff exp got
133
134 :