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