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 # This test requires a working a working `expect' program.
43 # Creative quoting required to avoid spurious maintainer-check failure.
44 (set +e; expect -c 'exit ''77'; test $? -eq 77) \
45 || skip_ "requires a working expect program"
47 # Also, if the $MAKE program fails to consider the standard output as a
48 # tty (this happens with e.g., BSD make and Solaris dmake when they're
49 # run in parallel mode; see the autoconf manual), there is little point
51 cat > Makefile <<'END'
53 ## Creative quoting in the `echo' below to avoid risk of spurious output
54 ## matches by `expect', below.
55 @test -t 1 && echo "stdout" "is" "a" "tty"
58 cat > expect-check <<'END'
61 "stdout is a tty" { exit 0 }
66 MAKE=$MAKE expect -f expect-check \
67 || skip_ "make spawned by expect should have a tty stdout"
68 rm -f expect-check Makefile
72 cat >>configure.in <<END
76 cat >Makefile.am <<'END'
77 AUTOMAKE_OPTIONS = color-tests
78 TESTS = $(check_SCRIPTS)
79 check_SCRIPTS = pass fail skip xpass xfail error
80 XFAIL_TESTS = xpass xfail
105 chmod +x pass fail skip xpass xfail error
109 $AUTOMAKE --add-missing
113 # Not a useless use of cat; see above comments about grep.
114 cat stdout | grep "^${grn}PASS${std}: .*pass"
115 cat stdout | grep "^${red}FAIL${std}: .*fail"
116 cat stdout | grep "^${blu}SKIP${std}: .*skip"
117 cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
118 cat stdout | grep "^${red}XPASS${std}: .*xpass"
119 # The old serial testsuite driver doesn't distinguish between failures
121 if test x"$am_parallel_tests" = x"yes"; then
122 cat stdout | grep "^${mgn}ERROR${std}: .*error"
124 cat stdout | grep "^${red}FAIL${std}: .*error"
131 # With make implementations that, like Solaris make, in case of errors
132 # print the whole failing recipe on standard output, we should content
133 # ourselves with a laxer check, to avoid false positives.
134 # Keep this in sync with lib/am/check.am:$(am__color_tests).
135 if $FGREP '= Xalways || test -t 1 ' stdout; then
136 # Extra verbose make, resort to laxer checks.
137 # Note that we also want to check that the testsuite summary is
138 # not unduly colorized.
140 set +e # In case some grepped regex below isn't matched.
141 # Not a useless use of cat; see above comments about grep.
142 cat stdout | grep "TOTAL.*:"
143 cat stdout | grep "PASS.*:"
144 cat stdout | grep "FAIL.*:"
145 cat stdout | grep "SKIP.*:"
146 cat stdout | grep "XFAIL.*:"
147 cat stdout | grep "XPASS.*:"
148 cat stdout | grep "ERROR.*:"
149 cat stdout | grep 'test.*expected'
150 cat stdout | grep 'test.*not run'
151 cat stdout | grep '===='
152 cat stdout | grep '[Ss]ee .*test-suite\.log'
153 cat stdout | grep '[Tt]estsuite summary'
154 ) | grep "$esc" && Exit 1
155 : For shells with broken 'set -e'
157 cat stdout | grep "$esc" && Exit 1
158 : For shells with broken 'set -e'
162 cat >expect-make <<'END'
163 eval spawn $env(MAKE) -e check
167 for vpath in false :; do
179 MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
180 || { cat stdout; Exit 1; }
184 AM_COLOR_TESTS=no MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
185 || { cat stdout; Exit 1; }