Merge branch 'improve-release-process' into maint
[automake.git] / t / tap-global-result.sh
blob528c7bb5e4fed4a422973b43bd0d05787b8c14f8
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 # - which global test result derives from different test results
19 # mixed in a single script?
21 . ./defs || exit 1
23 . tap-setup.sh
25 cat > ok.test <<END
26 1..3
27 ok 1
28 not ok 2 # TODO
29 ok 3 # SKIP
30 END
32 cat > skip.test <<'END'
33 1..3
34 ok 1 # SKIP
35 ok 2 # SKIP
36 ok 3 # SKIP
37 END
39 cat > skipall.test <<'END'
40 1..0 # SKIP
41 foo
42 # bar
43 END
45 cat > fail.test <<'END'
46 1..1
47 not ok 1
48 END
50 (sed '1s/.*/1..4/' ok.test && echo 'not ok 4') > fail2.test
52 cat > xpass.test <<'END'
53 1..1
54 ok 1 # TODO
55 END
57 (sed '1s/.*/1..4/' ok.test && echo 'ok 4 # TODO') > xpass2.test
59 echo 'Bail out!' > bail.test
61 (cat ok.test && echo 'Bail out!') > bail2.test
63 cat > bail3.test <<'END'
64 1..0 # SKIP
65 Bail out!
66 END
68 # Too many tests.
69 cat > error.test <<'END'
70 1..2
71 ok 1
72 ok 2 # SKIP
73 not ok 3
74 not ok 4 # TODO
75 END
77 # Too few tests.
78 cat > error2.test <<'END'
79 1..4
80 ok 1
81 not ok 2 # TODO
82 ok 3 # SKIP
83 END
85 # Repeated plan.
86 cat > error3.test <<'END'
87 1..2
88 1..2
89 ok 1
90 ok 2
91 END
93 # Too many tests, after a "SKIP" plan.
94 cat > error4.test <<'END'
95 1..0 # SKIP
96 ok 1
97 ok 2
98 END
100 # Tests out of order.
101 cat > error5.test <<'END'
102 1..4
103 not ok 1 # TODO
104 ok 3
105 ok 2
106 ok 4
109 # Wrong test number.
110 cat > error6.test <<'END'
111 1..2
112 ok 1 # SKIP
113 ok 7
116 # No plan.
117 cat > error7.test <<'END'
118 ok 1 # SKIP
119 ok 2 # TODO
120 not ok 3 # TODO
121 ok 4
124 cat > hodgepodge.test <<'END'
125 1..2
126 not ok 1
127 ok 2 # TODO
128 Bail out!
131 cat > hodgepodge-all.test <<'END'
132 1..4
133 ok 1
134 ok 2 # SKIP
135 not ok 2 # TODO
136 not ok 3
137 ok 4 # TODO
138 Bail out!
141 tests=$(echo *.test) # Also required later.
143 TESTS="$tests" $MAKE -e check >stdout && { cat stdout; exit 1; }
144 cat stdout
146 # Dirty trick required here.
147 for tst in $(echo " $tests " | sed 's/\.test / /'); do
148 echo :copy-in-global-log: yes >> $tst.trs
149 done
151 rm -f test-suite.log
152 TESTS="$tests" $MAKE -e test-suite.log && exit 1
153 cat test-suite.log
155 have_rst_section ()
157 eqeq=$(echo "$1" | sed 's/./=/g')
158 # Assume $1 contains no RE metacharacters.
159 sed -n "/^$1$/,/^$eqeq$/p" test-suite.log > got
160 (echo "$1" && echo "$eqeq") > exp
161 cat exp
162 cat got
163 diff exp got
166 have_rst_section 'PASS: ok'
167 have_rst_section 'SKIP: skip'
168 have_rst_section 'SKIP: skipall'
169 have_rst_section 'FAIL: fail'
170 have_rst_section 'FAIL: fail2'
171 have_rst_section 'FAIL: xpass'
172 have_rst_section 'FAIL: xpass2'
173 have_rst_section 'ERROR: bail'
174 have_rst_section 'ERROR: bail2'
175 have_rst_section 'ERROR: bail3'
176 have_rst_section 'ERROR: error'
177 have_rst_section 'ERROR: error2'
178 have_rst_section 'ERROR: error3'
179 have_rst_section 'ERROR: error4'
180 have_rst_section 'ERROR: error5'
181 have_rst_section 'ERROR: error6'
182 have_rst_section 'ERROR: error7'
183 have_rst_section 'ERROR: hodgepodge'
184 have_rst_section 'ERROR: hodgepodge-all'