doc: typos in test file.
[automake.git] / t / tap-plan-corner.sh
blobf14a522fdb573d2409cedb2fde792b4d376ac497
1 #! /bin/sh
2 # Copyright (C) 2011-2024 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 <https://www.gnu.org/licenses/>.
17 # TAP support:
18 # - some corner cases for TAP plan
20 . test-init.sh
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 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
44 # -------------------------------------------------------------------------
46 cat > leading-repeated.test <<END
47 1..2
48 ok 1
49 1..2
50 ok 2
51 END
53 cat > trailing-repeated.test <<END
54 ok 1
55 1..2
56 ok 2
57 1..2
58 END
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
68 # -------------------------------------------------------------------------
70 cat > 1.test <<END
71 1..0
72 1..0
73 END
75 cat > 2.test <<END
76 1..0 # SKIP
77 1..0
78 END
80 cat > 3.test <<END
81 1..0
82 1..0 # SKIP
83 END
85 cat > 4.test <<END
86 1..0 # SKIP
87 1..0 # SKIP
88 END
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
96 # -------------------------------------------------------------------------
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
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
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
124 $FGREP ': all.test' stdout > got
126 cat exp
127 cat got
128 diff exp got
130 # -------------------------------------------------------------------------
132 cat > all.test <<END
133 1..2
134 ok 1
135 ok 2
136 1..3
137 ok 3
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
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)
151 $FGREP ': all.test' stdout > got
153 cat exp
154 cat got
155 diff exp got
157 # -------------------------------------------------------------------------
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
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
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
183 $FGREP ': all.test' stdout > got
185 cat exp
186 cat got
187 diff exp got