maint: run "make update-copyright"
[platform/upstream/automake.git] / tests / tap-whitespace-normalization.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: whitespace normalization (or lack thereof) in the testsuite
18 # progress output on console.  We keep all these checks here in a single
19 # script so that a potential cosmetic change in the output format won't
20 # force us to tweak dozens of other tests (hopefully).
21 # See also related test 'tap-todo-skip-whitespace.test'.
22
23 am_parallel_tests=yes
24 . ./defs || Exit 1
25
26 cat > Makefile.am << 'END'
27 TEST_LOG_COMPILER = cat
28 TESTS =
29 END
30
31 : > exp
32
33 spaces_a=${sp}${tab}${tab}${sp}${sp}${tab}
34 spaces_b=${tab}${tab}${sp}${tab}${sp}${sp}${sp}
35
36 #-----------------------------------------------------------------------
37
38 echo TESTS += numbers.test >> Makefile.am
39
40 cat > numbers.test <<END
41 1..6
42 ok${spaces_a}1
43 ok 2${spaces_b}
44 ok${spaces_a}3${spaces_b}
45 not ok${spaces_b}4
46 not ok 5${spaces_a}
47 not ok${spaces_b}6${spaces_a}
48 END
49
50 cat >> exp <<END
51 PASS: numbers.test 1
52 PASS: numbers.test 2
53 PASS: numbers.test 3
54 FAIL: numbers.test 4
55 FAIL: numbers.test 5
56 FAIL: numbers.test 6
57 END
58
59 #-----------------------------------------------------------------------
60
61 echo TESTS += description.test >> Makefile.am
62
63 cat > description.test <<END
64 1..8
65 ok${spaces_a}+foo
66 ok +bar${spaces_b}
67 ok${spaces_a}+baz${spaces_b}
68 not ok${spaces_b}-foo
69 not ok -bar${spaces_a}
70 not ok${spaces_b}-baz${spaces_a}
71 ok  u${spaces_b}v${spaces_a}w${sp}
72 not ok${spaces_a}x${spaces_a}y${tab}z${tab}
73 END
74
75 cat >> exp <<END
76 PASS: description.test 1 +foo
77 PASS: description.test 2 +bar
78 PASS: description.test 3 +baz
79 FAIL: description.test 4 -foo
80 FAIL: description.test 5 -bar
81 FAIL: description.test 6 -baz
82 PASS: description.test 7 u${spaces_b}v${spaces_a}w
83 FAIL: description.test 8 x${spaces_a}y${tab}z
84 END
85
86 #-----------------------------------------------------------------------
87
88 # "Bail out!" magic.
89
90 echo TESTS += bailout.test >> Makefile.am
91
92 cat > bailout.test <<END
93 1..1
94 Bail out!${tab}${sp}${sp}${tab}We're out of disk space.
95 ok 1
96 END
97
98 cat >> exp <<END
99 ERROR: bailout.test - Bail out! We're out of disk space.
100 END
101
102 echo TESTS += bailout2.test >> Makefile.am
103
104 cat > bailout2.test <<END
105 1..1
106 Bail out!foo${tab}${sp}
107 ok 1
108 END
109
110 cat >> exp <<END
111 ERROR: bailout2.test - Bail out! foo
112 END
113
114 #-----------------------------------------------------------------------
115
116 # Diagnostic lines.
117
118 echo AM_TEST_LOG_DRIVER_FLAGS = --comments >> Makefile.am
119 echo TESTS += cmnt.test >> Makefile.am
120
121 cat > cmnt.test <<END
122 1..1
123 ok 1
124 #Leading whitespace gets added
125 #   ${tab}${tab} ${tab}Extra leading whitespace is stripped
126 # Trailing whitespace is stripped ${tab}   ${tab}${tab}
127 # Middle${tab}whitespace  is${tab}  ${tab}${tab}    kept
128 # ${tab} And  only${tab}middle ${tab}whitespace  ${tab}${tab} ${tab}
129 END
130
131 cat >> exp <<END
132 PASS: cmnt.test 1
133 # cmnt.test: Leading whitespace gets added
134 # cmnt.test: Extra leading whitespace is stripped
135 # cmnt.test: Trailing whitespace is stripped
136 # cmnt.test: Middle${tab}whitespace  is${tab}  ${tab}${tab}    kept
137 # cmnt.test: And  only${tab}middle ${tab}whitespace
138 END
139
140 #-----------------------------------------------------------------------
141
142 # TODO: we should have more checks here ... (but let's not over-do FTM).
143
144 #-----------------------------------------------------------------------
145
146 chmod a+x *.test
147
148 . "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
149
150 # Don't care about exit status or number of test results, they should be
151 # checked for in many other tests.
152 $MAKE check >stdout || :
153 cat stdout
154
155 LC_ALL=C sort exp > t
156 mv -f t exp
157
158 # We need the sort below to account for parallel make usage.
159 LC_ALL=C grep '[a-z0-9][a-z0-9]*\.test' stdout | LC_ALL=C sort > got
160
161 cat exp
162 cat got
163 diff exp got
164
165 :