2 # Copyright (C) 2011-2012 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)
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 <http://www.gnu.org/licenses/>.
18 # - colorization of TAP results and diagnostic messages
23 TERM
=ansi
; export TERM
26 # Escape `[' for grep, below.
34 # Check that grep can parse nonprinting characters.
35 # BSD 'grep' works from a pipe, but not a seekable file.
36 # GNU or BSD 'grep -a' works on files, but is not portable.
37 case `echo "$std" | grep .` in
39 *) echo "$me: grep can't parse nonprinting characters" >&2; Exit
77;;
42 cat > Makefile.am
<< 'END'
43 AUTOMAKE_OPTIONS
= color-tests
44 AM_TEST_LOG_DRIVER_FLAGS
= --comments
45 TEST_LOG_COMPILER
= cat
46 TESTS
= all.
test skip.
test bail.
test badplan.
test noplan.
test \
47 few.
test many.
test order.
test afterlate.
test
50 .
"$testsrcdir"/tap-setup.sh || fatal_
"sourcing tap-setup.sh"
52 cat > all.
test << 'END'
55 # Hi! I shouldn't be colorized!
56 not ok
2 - bar
# TODO td
62 cat > skip.
test << 'END'
63 1.
.0 # SKIP whole script
66 cat > bail.
test << 'END'
72 cat > badplan.
test << 'END'
79 cat > noplan.
test << 'END'
83 cat > few.
test << 'END'
88 cat > many.
test << 'END'
94 cat > order.
test << 'END'
99 cat > afterlate.
test << 'END'
105 AM_COLOR_TESTS
=always
$MAKE check
>stdout
&& { cat stdout
; Exit
1; }
110 # Not a useless use of cat; see above comments about grep.
111 cat stdout |
grep "^${grn}PASS${std}: all\.test 1 - foo$"
112 cat stdout |
grep "^${lgn}XFAIL${std}: all\.test 2 - bar # TODO td$"
113 cat stdout |
grep "^${blu}SKIP${std}: all\.test 3 - baz # SKIP sk$"
114 cat stdout |
grep "^${red}FAIL${std}: all\.test 4 - quux$"
115 cat stdout |
grep "^${red}XPASS${std}: all\.test 5 - zardoz # TODO$"
116 cat stdout |
grep "^${blu}SKIP${std}: skip\.test - whole script$"
117 cat stdout |
grep "^${grn}PASS${std}: bail\.test 1$"
118 cat stdout |
grep "^${mgn}ERROR${std}: bail\.test - Bail out!$"
119 cat stdout |
grep "^${mgn}ERROR${std}: badplan\.test - multiple test plans$"
120 cat stdout |
grep "^${mgn}ERROR${std}: noplan\.test - missing test plan$"
121 cat stdout |
grep "^${mgn}ERROR${std}: few.test - too few tests run (expected 2, got 1)$"
122 cat stdout |
grep "^${mgn}ERROR${std}: many.test - too many tests run (expected 1, got 2)$"
123 cat stdout |
grep "^${mgn}ERROR${std}: many.test 2 # UNPLANNED$"
124 cat stdout |
grep "^${mgn}ERROR${std}: order.test 5 # OUT-OF-ORDER (expecting 1)$"
125 cat stdout |
grep "^${mgn}ERROR${std}: afterlate\.test 2 # AFTER LATE PLAN$"
126 # Diagnostic messages shouldn't be colorized.
127 cat stdout |
grep "^# all\.test: Hi! I shouldn't be colorized!$"
133 # With make implementations that, like Solaris make, in case of errors
134 # print the whole failing recipe on standard output, we should content
135 # ourselves with a laxer check, to avoid false positives.
136 # Keep this in sync with lib/am/check.am:$(am__color_tests).
137 if $FGREP '= Xalways || test -t 1 ' stdout
; then
138 # Extra verbose make, resort to laxer checks.
139 # But we also want to check that the testsuite summary is not unduly
142 set +e
# In case some grepped regex below isn't matched.
143 # Not a useless use of cat; see above comments about grep.
144 cat stdout |
grep "TOTAL.*:"
145 cat stdout |
grep "PASS.*:"
146 cat stdout |
grep "FAIL.*:"
147 cat stdout |
grep "SKIP.*:"
148 cat stdout |
grep "XFAIL.*:"
149 cat stdout |
grep "XPASS.*:"
150 cat stdout |
grep "ERROR.*:"
151 cat stdout |
grep "^#"
152 cat stdout |
grep 'test.*expected'
153 cat stdout |
grep 'test.*not run'
154 cat stdout |
grep '===='
155 cat stdout |
grep '[Ss]ee .*test-suite\.log'
156 cat stdout |
grep '[Tt]estsuite summary'
157 ) |
grep "$esc" && Exit
1
158 : For shells with broken
'set -e'
160 cat stdout |
grep "$esc" && Exit
1
161 : For shells with broken
'set -e'
165 AM_COLOR_TESTS
=always
$MAKE check
>stdout
&& { cat stdout
; Exit
1; }
169 $MAKE -e check
>stdout
&& { cat stdout
; Exit
1; }