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