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