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