tests: less uses of "make -e"; avoid spurious failures in 'check-cc-no-c-o'
[platform/upstream/automake.git] / t / tap-plan-corner.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 # TAP support:
18 #  - some corner cases for TAP plan
19
20 . test-init.sh
21
22 . tap-setup.sh
23
24 # -------------------------------------------------------------------------
25
26 cat > leading-repeated.test <<END
27 1..1
28 1..1
29 ok 1
30 END
31
32 cat > trailing-repeated.test <<END
33 ok 1
34 1..1
35 1..1
36 END
37
38 for pos in leading trailing; do
39   TESTS="$pos-repeated.test" $MAKE -e check >stdout \
40     && { cat stdout; exit 1; }
41   cat stdout
42   count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
43   grep "^ERROR: $pos-repeated\\.test - multiple test plans$" stdout
44 done
45
46 # -------------------------------------------------------------------------
47
48 cat > leading-repeated.test <<END
49 1..2
50 ok 1
51 1..2
52 ok 2
53 END
54
55 cat > trailing-repeated.test <<END
56 ok 1
57 1..2
58 ok 2
59 1..2
60 END
61
62 env TESTS="leading-repeated.test trailing-repeated.test" \
63   $MAKE -e check >stdout && { cat stdout; exit 1; }
64 cat stdout
65 count_test_results total=6 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=3
66 grep "^ERROR: leading-repeated\\.test - multiple test plans$" stdout
67 grep "^ERROR: trailing-repeated\\.test - multiple test plans$" stdout
68 grep "^ERROR: trailing-repeated\\.test 2 # AFTER LATE PLAN$" stdout
69 grep "leading .*AFTER LATE PLAN" stdout && exit 1
70
71 # -------------------------------------------------------------------------
72
73 cat > 1.test <<END
74 1..0
75 1..0
76 END
77
78 cat > 2.test <<END
79 1..0 # SKIP
80 1..0
81 END
82
83 cat > 3.test <<END
84 1..0
85 1..0 # SKIP
86 END
87
88 cat > 4.test <<END
89 1..0 # SKIP
90 1..0 # SKIP
91 END
92
93 env TESTS="1.test 2.test 3.test 4.test" \
94   $MAKE -e check >stdout && { cat stdout; exit 1; }
95 cat stdout
96 count_test_results total=8 pass=0 fail=0 xpass=0 xfail=0 skip=4 error=4
97 for i in 1 2 3 4; do
98   grep "^ERROR: $i\\.test - multiple test plans$" stdout
99 done
100
101 # -------------------------------------------------------------------------
102
103 cat > all.test <<END
104 1..5
105 ok 1
106 ok 2
107 1..5
108 ok 3
109 1..5
110 ok 4
111 1..5
112 ok 5
113 END
114
115 $MAKE -e check >stdout && { cat stdout; exit 1; }
116 cat stdout
117 count_test_results total=8 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=3
118
119 cat > exp <<'END'
120 PASS: all.test 1
121 PASS: all.test 2
122 ERROR: all.test - multiple test plans
123 PASS: all.test 3
124 ERROR: all.test - multiple test plans
125 PASS: all.test 4
126 ERROR: all.test - multiple test plans
127 PASS: all.test 5
128 END
129
130 $FGREP ': all.test' stdout > got
131
132 cat exp
133 cat got
134 diff exp got
135
136 # -------------------------------------------------------------------------
137
138 cat > all.test <<END
139 1..2
140 ok 1
141 ok 2
142 1..3
143 ok 3
144 END
145
146 $MAKE -e check >stdout && { cat stdout; exit 1; }
147 cat stdout
148 count_test_results total=5 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=3
149
150 cat > exp <<'END'
151 PASS: all.test 1
152 PASS: all.test 2
153 ERROR: all.test - multiple test plans
154 ERROR: all.test 3 # UNPLANNED
155 ERROR: all.test - too many tests run (expected 2, got 3)
156 END
157
158 $FGREP ': all.test' stdout > got
159
160 cat exp
161 cat got
162 diff exp got
163
164 # -------------------------------------------------------------------------
165
166 cat > all.test <<END
167 ok 1
168 ok 2
169 ok 3
170 1..5
171 1..5
172 ok 4
173 1..5
174 ok 5
175 END
176
177 $MAKE -e check >stdout && { cat stdout; exit 1; }
178 cat stdout
179 count_test_results total=7 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=4
180
181 cat > exp <<'END'
182 PASS: all.test 1
183 PASS: all.test 2
184 PASS: all.test 3
185 ERROR: all.test - multiple test plans
186 ERROR: all.test 4 # AFTER LATE PLAN
187 ERROR: all.test - multiple test plans
188 ERROR: all.test 5 # AFTER LATE PLAN
189 END
190
191 $FGREP ': all.test' stdout > got
192
193 cat exp
194 cat got
195 diff exp got
196
197 :