tests: remove recipes that run tests with 'prove'
[platform/upstream/automake.git] / tests / tap-unplanned.test
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 #  - unplanned tests are properly reported as errors
19
20 am_parallel_tests=yes
21 . ./defs || Exit 1
22
23 . "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
24
25 cat > all.test <<END
26 1..1
27 ok 1
28 ok 2
29 END
30 $MAKE check >stdout && { cat stdout; Exit 1; }
31 cat stdout
32 count_test_results total=3 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=2
33 grep '^ERROR: all\.test - too many tests run (expected 1, got 2)$' stdout
34 grep '^ERROR: all\.test 2 # UNPLANNED$' stdout
35
36 cat > all.test <<END
37 1..2
38 ok 1
39 ok 2
40 ok 3
41 END
42 $MAKE check >stdout && { cat stdout; Exit 1; }
43 cat stdout
44 count_test_results total=4 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=2
45 grep '^ERROR: all\.test - too many tests run (expected 2, got 3)$' stdout
46 grep '^ERROR: all\.test 3 # UNPLANNED$' stdout
47
48 # Interaction with XFAIL_TESTS.
49 cat > all.test <<END
50 1..2
51 not ok 1
52 ok 2 # SKIP
53 ok 3
54 not ok 4
55 ok 5 # SKIP
56 END
57 XFAIL_TESTS=all.test $MAKE -e check >stdout && { cat stdout; Exit 1; }
58 cat stdout
59 count_test_results total=6 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=4
60 grep '^ERROR: all\.test - too many tests run (expected 2, got 5)$' stdout
61 grep '^ERROR: all\.test 3 # UNPLANNED$' stdout
62 grep '^ERROR: all\.test 4 # UNPLANNED$' stdout
63 grep '^ERROR: all\.test 5 # UNPLANNED$' stdout
64
65 cat > all.test <<END
66 1..1
67 ok 1
68
69 ok
70 ok 3
71 ok foo
72 ok 5 - bar bar
73
74 not ok
75 not ok 7
76 not ok foo
77 not ok 9 - bar bar
78
79 ok # TODO
80 ok 11 # TODO
81 ok foo # TODO
82 ok 13 - bar bar # TODO
83
84 not ok # TODO
85 not ok 15 # TODO
86 not ok foo # TODO
87 not ok 17 - bar bar # TODO
88
89 ok # SKIP
90 ok 19 # SKIP
91 ok foo # SKIP
92 ok 21 - bar bar # SKIP
93 END
94
95 cat > t <<END
96
97 2
98 3
99 4 foo
100 5 - bar bar
101
102 6
103 7
104 8 foo
105 9 - bar bar
106
107 10
108 11
109 12 foo
110 13 - bar bar
111
112 14
113 15
114 16 foo
115 17 - bar bar
116
117 18
118 19
119 20 foo
120 21 - bar bar
121
122 END
123
124 $MAKE check >stdout && { cat stdout; Exit 1; }
125 cat stdout
126 count_test_results total=22 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=21
127
128 echo 'PASS: all.test 1' > exp
129 sed -e '/^$/d' -e 's/.*/ERROR: all.test & # UNPLANNED/' t >> exp
130 echo 'ERROR: all.test - too many tests run (expected 1, got 21)' >> exp
131
132 $FGREP ': all.test' stdout > got
133
134 cat exp
135 cat got
136 diff exp got
137
138 # Note that, if the TAP input has a trailing plan, it is not possible
139 # to flag unplanned tests as such, since we do not know they're unplanned
140 # until the plan is reached; still, we should give at least an error
141 # message about the unmatched number of tests once we've got the plan.
142
143 for x in 'ok' 'ok 3' 'not ok' 'not ok # TODO' 'ok # TODO' 'ok # SKIP'; do
144   unindent > all.test <<END
145     ok 1
146     ok 2 # SKIP
147     $x
148     1..2
149 END
150   $MAKE check >stdout && { cat stdout; Exit 1; }
151   cat stdout
152   test `$FGREP -c ': all.test' stdout` -eq 4
153   $EGREP '^PASS: all\.test 1($| )' stdout
154   $EGREP '^SKIP: all\.test 2($| )' stdout
155   $EGREP ': all\.test 3($| )' stdout
156   grep '^ERROR: all\.test - too many tests run (expected 2, got 3)$' stdout
157 done
158
159 :