tests: expose automake bug#14560
[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   run_make -O -e FAIL TESTS="$pos-repeated.test" check
40   count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
41   grep "^ERROR: $pos-repeated\\.test - multiple test plans$" stdout
42 done
43
44 # -------------------------------------------------------------------------
45
46 cat > leading-repeated.test <<END
47 1..2
48 ok 1
49 1..2
50 ok 2
51 END
52
53 cat > trailing-repeated.test <<END
54 ok 1
55 1..2
56 ok 2
57 1..2
58 END
59
60 run_make -O -e FAIL check \
61   TESTS='leading-repeated.test trailing-repeated.test'
62 count_test_results total=6 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=3
63 grep "^ERROR: leading-repeated\\.test - multiple test plans$" stdout
64 grep "^ERROR: trailing-repeated\\.test - multiple test plans$" stdout
65 grep "^ERROR: trailing-repeated\\.test 2 # AFTER LATE PLAN$" stdout
66 grep "leading .*AFTER LATE PLAN" stdout && exit 1
67
68 # -------------------------------------------------------------------------
69
70 cat > 1.test <<END
71 1..0
72 1..0
73 END
74
75 cat > 2.test <<END
76 1..0 # SKIP
77 1..0
78 END
79
80 cat > 3.test <<END
81 1..0
82 1..0 # SKIP
83 END
84
85 cat > 4.test <<END
86 1..0 # SKIP
87 1..0 # SKIP
88 END
89
90 run_make -O -e FAIL check TESTS='1.test 2.test 3.test 4.test'
91 count_test_results total=8 pass=0 fail=0 xpass=0 xfail=0 skip=4 error=4
92 for i in 1 2 3 4; do
93   grep "^ERROR: $i\\.test - multiple test plans$" stdout
94 done
95
96 # -------------------------------------------------------------------------
97
98 cat > all.test <<END
99 1..5
100 ok 1
101 ok 2
102 1..5
103 ok 3
104 1..5
105 ok 4
106 1..5
107 ok 5
108 END
109
110 run_make -O -e FAIL check
111 count_test_results total=8 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=3
112
113 cat > exp <<'END'
114 PASS: all.test 1
115 PASS: all.test 2
116 ERROR: all.test - multiple test plans
117 PASS: all.test 3
118 ERROR: all.test - multiple test plans
119 PASS: all.test 4
120 ERROR: all.test - multiple test plans
121 PASS: all.test 5
122 END
123
124 $FGREP ': all.test' stdout > got
125
126 cat exp
127 cat got
128 diff exp got
129
130 # -------------------------------------------------------------------------
131
132 cat > all.test <<END
133 1..2
134 ok 1
135 ok 2
136 1..3
137 ok 3
138 END
139
140 run_make -O -e FAIL check
141 count_test_results total=5 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=3
142
143 cat > exp <<'END'
144 PASS: all.test 1
145 PASS: all.test 2
146 ERROR: all.test - multiple test plans
147 ERROR: all.test 3 # UNPLANNED
148 ERROR: all.test - too many tests run (expected 2, got 3)
149 END
150
151 $FGREP ': all.test' stdout > got
152
153 cat exp
154 cat got
155 diff exp got
156
157 # -------------------------------------------------------------------------
158
159 cat > all.test <<END
160 ok 1
161 ok 2
162 ok 3
163 1..5
164 1..5
165 ok 4
166 1..5
167 ok 5
168 END
169
170 run_make -O -e FAIL check
171 count_test_results total=7 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=4
172
173 cat > exp <<'END'
174 PASS: all.test 1
175 PASS: all.test 2
176 PASS: all.test 3
177 ERROR: all.test - multiple test plans
178 ERROR: all.test 4 # AFTER LATE PLAN
179 ERROR: all.test - multiple test plans
180 ERROR: all.test 5 # AFTER LATE PLAN
181 END
182
183 $FGREP ': all.test' stdout > got
184
185 cat exp
186 cat got
187 diff exp got
188
189 :