Merge branch 'python-fix-pr10227' into maint
[automake.git] / t / tap-plan-corner.sh
blob8fc0c7e0f9de2d7215606ae7a4969d8f0b80bcdc
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # TAP support:
18 # - some corner cases for TAP plan
20 . ./defs || exit 1
22 . tap-setup.sh
24 # -------------------------------------------------------------------------
26 cat > leading-repeated.test <<END
27 1..1
28 1..1
29 ok 1
30 END
32 cat > trailing-repeated.test <<END
33 ok 1
34 1..1
35 1..1
36 END
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
46 # -------------------------------------------------------------------------
48 cat > leading-repeated.test <<END
49 1..2
50 ok 1
51 1..2
52 ok 2
53 END
55 cat > trailing-repeated.test <<END
56 ok 1
57 1..2
58 ok 2
59 1..2
60 END
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
71 # -------------------------------------------------------------------------
73 cat > 1.test <<END
74 1..0
75 1..0
76 END
78 cat > 2.test <<END
79 1..0 # SKIP
80 1..0
81 END
83 cat > 3.test <<END
84 1..0
85 1..0 # SKIP
86 END
88 cat > 4.test <<END
89 1..0 # SKIP
90 1..0 # SKIP
91 END
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
101 # -------------------------------------------------------------------------
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
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
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
130 $FGREP ': all.test' stdout > got
132 cat exp
133 cat got
134 diff exp got
136 # -------------------------------------------------------------------------
138 cat > all.test <<END
139 1..2
140 ok 1
141 ok 2
142 1..3
143 ok 3
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
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)
158 $FGREP ': all.test' stdout > got
160 cat exp
161 cat got
162 diff exp got
164 # -------------------------------------------------------------------------
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
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
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
191 $FGREP ': all.test' stdout > got
193 cat exp
194 cat got
195 diff exp got