ylwrap: preserve subdirectories in "#line" munging
[platform/upstream/automake.git] / t / tap-passthrough.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 #  - all input (valid TAP lines, invalid TAP lines, non-TAP lines)
19 #    are passed through in the log file
20 #  - TAP errors are reported in the log file too
21 # See also related test 'tap-passthrough-exit.test'.
22
23 am_parallel_tests=yes
24 . ./defs || Exit 1
25
26 weirdchars=\''"\$@!&()[]<>#;,:.^?*/'
27
28 . "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
29
30 #
31 # Only successful tests.
32 #
33
34 # The whitespace in this test might be normalized in the testsuite
35 # progress output, but should be copied verbatim in the log files.
36 cat > ok.test <<END
37 1..6
38 TAP plan in the previous line.
39 ok${tab}
40 ok     2
41 ok - foo
42 ok 4 - x
43   This is not a TAP line, but should still be copied in the log file!
44 # some diagnostic${tab}
45 not ok # TODO low priority
46 ok # SKIP who cares?
47 $weirdchars
48 END
49
50 TESTS=ok.test $MAKE -e check || { cat ok.log; Exit 1; }
51 cat ok.log
52
53 for rx in \
54   '1\.\.6' \
55   'TAP plan in the previous line\.' \
56   "ok${tab}" \
57   'ok     2' \
58   'ok - foo' \
59   'ok 4 - x' \
60   '  This is not a TAP line, but should still be copied in the log file!' \
61   "# some diagnostic${tab}" \
62   'not ok # TODO low priority' \
63   'ok # SKIP who cares?' \
64 ; do
65   grep "^$rx$" ok.log
66 done
67 $FGREP "$weirdchars" ok.log
68
69 #
70 # Mixed failing/successful tests.
71 #
72
73 cat > tiny.test <<END
74 1..1
75 ok
76 END
77
78 cat > ok.test <<END
79 1..1
80 ok
81 only one success here
82 END
83
84 cat > ko.test <<END
85 1..5
86 foo foo foo
87 ok${tab}
88 ok     2
89 not ok - foo
90 not ok 4 - x
91 # diagnostic ko
92   bar${tab}bar${tab}bar
93 ok # TODO dunno
94 $weirdchars
95 END
96
97 cat > bail.test <<END
98 Bail out! Test is taking too long!
99 END
100
101 cat > skip.test <<END
102 1..0 # Skipped: WWW::Mechanize not installed
103 END
104
105 cat > err.test <<END
106 1..3
107 ok 1
108 Invalid test count
109 ok 23
110 Misplaced plan
111 1..13
112 ok
113 Extra test
114 ok
115 Last line
116 END
117
118 st=0
119 env TESTS='tiny.test ok.test ko.test bail.test skip.test err.test' \
120   $MAKE -e check || st=$?
121 cat tiny.log
122 cat ok.log
123 cat ko.log
124 cat bail.log
125 cat skip.log
126 cat err.log
127 test $st -gt 0 || Exit 1
128
129 grep '^1\.\.1$' tiny.log
130 grep '^ok$' tiny.log
131 grep '^only one success here$' ok.log
132
133 for rx in \
134   '1\.\.5' \
135   'foo foo foo' \
136   "ok${tab}" \
137   'ok     2' \
138   'not ok - foo' \
139   'not ok 4 - x' \
140   '# diagnostic ko' \
141   "  bar${tab}bar${tab}bar" \
142   'ok # TODO dunno' \
143 ; do
144   grep "^$rx$" ko.log
145 done
146 $FGREP "$weirdchars" ko.log
147
148 grep '^Bail out! Test is taking too long!$' bail.log
149 grep '^1\.\.0 # Skipped: WWW::Mechanize not installed$' skip.log
150
151 for rx in \
152   '^1\.\.3$' \
153   '^Invalid test count$' \
154   '^ok 23$' \
155   '^Misplaced plan$' \
156   '^1\.\.13$' \
157   '^ERROR:.* multiple test plans' \
158    '^Extra test$' \
159   '^Last line$' \
160   '^ERROR:.* [tT]oo many tests run.*expected 3, got 4' \
161   '^ERROR:.* err\.test 23 .*OUT[ -]OF[ -]ORDER.*expecting 2' \
162 ; do
163   grep "$rx" err.log
164 done
165
166 :