2 # Copyright (C) 2007-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/>.
17 # Test Automake TESTS color output, using the expect(1) program.
18 # Keep this in sync with the sister test 'color.test'.
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 *) skip_ "grep can't parse nonprinting characters";;
39 # This test requires a working a working 'expect' program.
40 # Creative quoting required to avoid spurious maintainer-check failure.
41 (set +e; expect -c 'exit ''77'; test $? -eq 77) \
42 || skip_ "requires a working expect program"
44 # Also, if the $MAKE program fails to consider the standard output as a
45 # tty (this happens with e.g., BSD make and Solaris dmake when they're
46 # run in parallel mode; see the autoconf manual), there is little point
48 cat > Makefile <<'END'
50 ## Creative quoting in the 'echo' below to avoid risk of spurious output
51 ## matches by 'expect', below.
52 @test -t 1 && echo "stdout" "is" "a" "tty"
55 cat > expect-check <<'END'
58 "stdout is a tty" { exit 0 }
63 MAKE=$MAKE expect -f expect-check \
64 || skip_ "make spawned by expect should have a tty stdout"
65 rm -f expect-check Makefile
69 cat >>configure.ac <<END
73 cat >Makefile.am <<'END'
74 AUTOMAKE_OPTIONS = color-tests
75 TESTS = $(check_SCRIPTS)
76 check_SCRIPTS = pass fail skip xpass xfail error
77 XFAIL_TESTS = xpass xfail
102 chmod +x pass fail skip xpass xfail error
106 $AUTOMAKE --add-missing
110 # Not a useless use of cat; see above comments about grep.
111 cat stdout | grep "^${grn}PASS${std}: .*pass"
112 cat stdout | grep "^${red}FAIL${std}: .*fail"
113 cat stdout | grep "^${blu}SKIP${std}: .*skip"
114 cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
115 cat stdout | grep "^${red}XPASS${std}: .*xpass"
116 # The old serial testsuite driver doesn't distinguish between failures
118 if test x"$am_parallel_tests" = x"yes"; then
119 cat stdout | grep "^${mgn}ERROR${std}: .*error"
121 cat stdout | grep "^${red}FAIL${std}: .*error"
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 # Note that we also want to check that the testsuite summary is
135 # not unduly colorized.
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 '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 cat >expect-make <<'END'
160 eval spawn $env(MAKE) -e check
164 for vpath in false :; do
176 TERM=ansi MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
177 || { cat stdout; Exit 1; }
181 TERM=dumb MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
182 || { cat stdout; Exit 1; }
186 AM_COLOR_TESTS=no MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
187 || { cat stdout; Exit 1; }