Merge branch 'minor'
[automake.git] / t / tap-whitespace-normalization.sh
blob4b767f5c1ab51cb47157cc29d18c98dc79859b34
1 #! /bin/sh
2 # Copyright (C) 2011-2017 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
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'.
23 . test-init.sh
25 cat > Makefile.am << 'END'
26 TEST_LOG_COMPILER = cat
27 TESTS =
28 END
30 : > exp
32 spaces_a=${sp}${tab}${tab}${sp}${sp}${tab}
33 spaces_b=${tab}${tab}${sp}${tab}${sp}${sp}${sp}
35 #-----------------------------------------------------------------------
37 echo TESTS += numbers.test >> Makefile.am
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
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
58 #-----------------------------------------------------------------------
60 echo TESTS += description.test >> Makefile.am
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
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
85 #-----------------------------------------------------------------------
87 # "Bail out!" magic.
89 echo TESTS += bailout.test >> Makefile.am
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
97 cat >> exp <<END
98 ERROR: bailout.test - Bail out! We're out of disk space.
99 END
101 echo TESTS += bailout2.test >> Makefile.am
103 cat > bailout2.test <<END
104 1..1
105 Bail out!foo${tab}${sp}
106 ok 1
109 cat >> exp <<END
110 ERROR: bailout2.test - Bail out! foo
113 #-----------------------------------------------------------------------
115 # Diagnostic lines.
117 echo AM_TEST_LOG_DRIVER_FLAGS = --comments >> Makefile.am
118 echo TESTS += cmnt.test >> Makefile.am
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}
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
139 #-----------------------------------------------------------------------
141 # TODO: we should have more checks here ... (but let's not over-do FTM).
143 #-----------------------------------------------------------------------
145 chmod a+x *.test
147 . tap-setup.sh
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
153 LC_ALL=C sort exp > t
154 mv -f t exp
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
159 cat exp
160 cat got
161 diff exp got