2 # Copyright (C) 2007, 2008, 2010, 2011 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/>.
17 # Test Automake TESTS color output, using the expect(1) program.
18 # Keep this in sync with the sister test `color.test'.
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 *) skip_ "grep can't parse nonprinting characters";;
42 # Check that we have a working expect program.
43 cat >expect-check <<'END'
45 eval spawn $env(THE_SYSTEM_SHELL) -c :
48 THE_SYSTEM_SHELL=/bin/sh expect -f expect-check \
49 || skip_ "$me: failed to find a working expect program"
53 cat >>configure.in <<END
57 cat >Makefile.am <<'END'
58 AUTOMAKE_OPTIONS = color-tests
59 TESTS = $(check_SCRIPTS)
60 check_SCRIPTS = pass fail skip xpass xfail error
61 XFAIL_TESTS = xpass xfail
86 chmod +x pass fail skip xpass xfail error
90 $AUTOMAKE --add-missing
94 # Not a useless use of cat; see above comments about grep.
95 cat stdout | grep "^${grn}PASS${std}: .*pass"
96 cat stdout | grep "^${red}FAIL${std}: .*fail"
97 cat stdout | grep "^${blu}SKIP${std}: .*skip"
98 cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
99 cat stdout | grep "^${red}XPASS${std}: .*xpass"
100 # The old serial testsuite driver doesn't distinguish between failures
102 if test x"$parallel_tests" = x"yes"; then
103 cat stdout | grep "^${mgn}ERROR${std}: .*error"
105 cat stdout | grep "^${red}FAIL${std}: .*error"
112 # With make implementations that, like Solaris make, in case of errors
113 # print the whole failing recipe on standard output, we should content
114 # ourselves with a laxer check, to avoid false positives.
115 # Keep this in sync with lib/am/check.am:$(am__color_tests).
116 if $FGREP '= Xalways || test -t 1 ' stdout; then
117 # Extra verbose make, resort to laxer checks.
118 # Note that we also want to check that the testsuite summary is
119 # not unduly colorized.
121 set +e # In case some grepped regex below isn't matched.
122 # Not a useless use of cat; see above comments about grep.
123 cat stdout | grep "TOTAL.*:"
124 cat stdout | grep "PASS.*:"
125 cat stdout | grep "FAIL.*:"
126 cat stdout | grep "SKIP.*:"
127 cat stdout | grep "XFAIL.*:"
128 cat stdout | grep "XPASS.*:"
129 cat stdout | grep "ERROR.*:"
130 cat stdout | grep 'test.*expected'
131 cat stdout | grep 'test.*not run'
132 cat stdout | grep '===='
133 cat stdout | grep '[Ss]ee .*test-suite\.log'
134 cat stdout | grep '[Tt]estsuite summary'
135 ) | grep "$esc" && Exit 1
136 : For shells with broken 'set -e'
138 cat stdout | grep "$esc" && Exit 1
139 : For shells with broken 'set -e'
143 cat >expect-make <<'END'
144 #! /usr/bin/expect -f
145 eval spawn $env(MAKE) -e check
149 for vpath in false :; do
161 MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
162 || { cat stdout; Exit 1; }
166 AM_COLOR_TESTS=no MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
167 || { cat stdout; Exit 1; }