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'.
20 # For gen-testsuite-part: ==> try-with-serial-tests <==
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 *) skip_ "grep can't parse nonprinting characters";;
40 # This test requires a working a working 'expect' program.
41 # Creative quoting required to avoid spurious maintainer-check failure.
42 (set +e; expect -c 'exit ''77'; test $? -eq 77) \
43 || skip_ "requires a working expect program"
45 # Also, if the $MAKE program fails to consider the standard output as a
46 # tty (this happens with e.g., BSD make and Solaris dmake when they're
47 # run in parallel mode; see the autoconf manual), there is little point
49 cat > Makefile <<'END'
51 ## Creative quoting in the 'echo' below to avoid risk of spurious output
52 ## matches by 'expect', below.
53 @test -t 1 && echo "stdout" "is" "a" "tty"
56 cat > expect-check <<'END'
59 "stdout is a tty" { exit 0 }
64 MAKE=$MAKE expect -f expect-check \
65 || skip_ "make spawned by expect should have a tty stdout"
66 rm -f expect-check Makefile
70 cat >>configure.ac <<END
74 cat >Makefile.am <<'END'
75 AUTOMAKE_OPTIONS = color-tests
76 TESTS = $(check_SCRIPTS)
77 check_SCRIPTS = pass fail skip xpass xfail error
78 XFAIL_TESTS = xpass xfail
103 chmod +x pass fail skip xpass xfail error
107 $AUTOMAKE --add-missing
111 # Not a useless use of cat; see above comments about grep.
112 cat stdout | grep "^${grn}PASS${std}: .*pass"
113 cat stdout | grep "^${red}FAIL${std}: .*fail"
114 cat stdout | grep "^${blu}SKIP${std}: .*skip"
115 cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
116 cat stdout | grep "^${red}XPASS${std}: .*xpass"
117 # The old serial testsuite driver doesn't distinguish between failures
119 if test x"$am_serial_tests" = x"yes"; then
120 cat stdout | grep "^${red}FAIL${std}: .*error"
122 cat stdout | grep "^${mgn}ERROR${std}: .*error"
129 # With make implementations that, like Solaris make, in case of errors
130 # print the whole failing recipe on standard output, we should content
131 # ourselves with a laxer check, to avoid false positives.
132 # Keep this in sync with lib/am/check.am:$(am__color_tests).
133 if $FGREP '= Xalways; then' stdout; then
134 # Extra verbose make, resort to laxer checks.
135 # Note that we also want to check that the testsuite summary is
136 # not unduly colorized.
138 set +e # In case some grepped regex below isn't matched.
139 # Not a useless use of cat; see above comments about grep.
140 cat stdout | grep "TOTAL.*:"
141 cat stdout | grep "PASS.*:"
142 cat stdout | grep "FAIL.*:"
143 cat stdout | grep "SKIP.*:"
144 cat stdout | grep "XFAIL.*:"
145 cat stdout | grep "XPASS.*:"
146 cat stdout | grep "ERROR.*:"
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 cat >expect-make <<'END'
161 eval spawn $env(MAKE) -e check
165 for vpath in false :; do
177 TERM=ansi MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
178 || { cat stdout; Exit 1; }
182 TERM=dumb MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
183 || { cat stdout; Exit 1; }
187 AM_COLOR_TESTS=no MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
188 || { cat stdout; Exit 1; }