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 # Escape '[' for grep, below.
31 # Check that grep can parse nonprinting characters.
32 # BSD 'grep' works from a pipe, but not a seekable file.
33 # GNU or BSD 'grep -a' works on files, but is not portable.
34 case `echo "$std" | grep .` in
36 *) echo "$me: grep can't parse nonprinting characters" >&2; Exit 77;;
39 cat > Makefile.am << 'END'
40 AUTOMAKE_OPTIONS = color-tests
41 AM_TEST_LOG_DRIVER_FLAGS = --comments
42 TEST_LOG_COMPILER = cat
43 TESTS = all.test skip.test bail.test badplan.test noplan.test \
44 few.test many.test order.test afterlate.test
47 . "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
49 cat > all.test << 'END'
52 # Hi! I shouldn't be colorized!
53 not ok 2 - bar # TODO td
59 cat > skip.test << 'END'
60 1..0 # SKIP whole script
63 cat > bail.test << 'END'
69 cat > badplan.test << 'END'
76 cat > noplan.test << 'END'
80 cat > few.test << 'END'
85 cat > many.test << 'END'
91 cat > order.test << 'END'
96 cat > afterlate.test << 'END'
104 # Not a useless use of cat; see above comments about grep.
105 cat stdout | grep "^${grn}PASS${std}: all\.test 1 - foo$"
106 cat stdout | grep "^${lgn}XFAIL${std}: all\.test 2 - bar # TODO td$"
107 cat stdout | grep "^${blu}SKIP${std}: all\.test 3 - baz # SKIP sk$"
108 cat stdout | grep "^${red}FAIL${std}: all\.test 4 - quux$"
109 cat stdout | grep "^${red}XPASS${std}: all\.test 5 - zardoz # TODO$"
110 cat stdout | grep "^${blu}SKIP${std}: skip\.test - whole script$"
111 cat stdout | grep "^${grn}PASS${std}: bail\.test 1$"
112 cat stdout | grep "^${mgn}ERROR${std}: bail\.test - Bail out!$"
113 cat stdout | grep "^${mgn}ERROR${std}: badplan\.test - multiple test plans$"
114 cat stdout | grep "^${mgn}ERROR${std}: noplan\.test - missing test plan$"
115 cat stdout | grep "^${mgn}ERROR${std}: few.test - too few tests run (expected 2, got 1)$"
116 cat stdout | grep "^${mgn}ERROR${std}: many.test - too many tests run (expected 1, got 2)$"
117 cat stdout | grep "^${mgn}ERROR${std}: many.test 2 # UNPLANNED$"
118 cat stdout | grep "^${mgn}ERROR${std}: order.test 5 # OUT-OF-ORDER (expecting 1)$"
119 cat stdout | grep "^${mgn}ERROR${std}: afterlate\.test 2 # AFTER LATE PLAN$"
120 # Diagnostic messages shouldn't be colorized.
121 cat stdout | grep "^# all\.test: Hi! I shouldn't be colorized!$"
127 # With make implementations that, like Solaris make, in case of errors
128 # print the whole failing recipe on standard output, we should content
129 # ourselves with a laxer check, to avoid false positives.
130 # Keep this in sync with lib/am/check.am:$(am__color_tests).
131 if $FGREP '= Xalways; then' stdout; then
132 # Extra verbose make, resort to laxer checks.
133 # But we also want to check that the testsuite summary is not unduly
136 set +e # In case some grepped regex below isn't matched.
137 # Not a useless use of cat; see above comments about grep.
138 cat stdout | grep "TOTAL.*:"
139 cat stdout | grep "PASS.*:"
140 cat stdout | grep "FAIL.*:"
141 cat stdout | grep "SKIP.*:"
142 cat stdout | grep "XFAIL.*:"
143 cat stdout | grep "XPASS.*:"
144 cat stdout | grep "ERROR.*:"
145 cat stdout | grep "^#"
146 cat stdout | grep 'test.*expected'
147 cat stdout | grep 'test.*not run'
148 cat stdout | grep '===='
149 cat stdout | grep '[Ss]ee .*test-suite\.log'
150 cat stdout | grep '[Tt]estsuite summary'
151 ) | grep "$esc" && Exit 1
152 : For shells with broken 'set -e'
154 cat stdout | grep "$esc" && Exit 1
155 : For shells with broken 'set -e'
159 # Forced colorization should take place also with non-ANSI terminals;
160 # hence the "TERM=dumb" definition.
161 TERM=dumb AM_COLOR_TESTS=always $MAKE check >stdout \
162 && { cat stdout; Exit 1; }
166 TERM=ansi $MAKE -e check >stdout \
167 && { cat stdout; Exit 1; }