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 required='grep-nonprint'
21 # For gen-testsuite-part: ==> try-with-serial-tests <==
24 # Escape '[' for grep, below.
32 # This test requires a working a working 'expect' program.
33 # Creative quoting required to avoid spurious maintainer-check failure.
34 (set +e; expect -c 'exit ''77'; test $? -eq 77) \
35 || skip_ "requires a working expect program"
37 # Also, if the $MAKE program fails to consider the standard output as a
38 # tty (this happens with e.g., BSD make and Solaris dmake when they're
39 # run in parallel mode; see the autoconf manual), there is little point
41 cat > Makefile <<'END'
43 ## Creative quoting in the 'echo' below to avoid risk of spurious output
44 ## matches by 'expect', below.
45 @test -t 1 && echo "stdout" "is" "a" "tty"
48 cat > expect-check <<'END'
51 "stdout is a tty" { exit 0 }
56 MAKE=$MAKE expect -f expect-check \
57 || skip_ "make spawned by expect should have a tty stdout"
58 rm -f expect-check Makefile
62 cat >>configure.ac <<END
66 cat >Makefile.am <<'END'
67 AUTOMAKE_OPTIONS = color-tests
68 TESTS = $(check_SCRIPTS)
69 check_SCRIPTS = pass fail skip xpass xfail error
70 XFAIL_TESTS = xpass xfail
95 chmod +x pass fail skip xpass xfail error
99 $AUTOMAKE --add-missing
103 # Not a useless use of cat; see above comments "grep-nonprinting"
104 # requirement in 'test-init.sh'.
105 cat stdout | grep "^${grn}PASS${std}: .*pass"
106 cat stdout | grep "^${red}FAIL${std}: .*fail"
107 cat stdout | grep "^${blu}SKIP${std}: .*skip"
108 cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
109 cat stdout | grep "^${red}XPASS${std}: .*xpass"
110 # The old serial testsuite driver doesn't distinguish between failures
112 if test x"$am_serial_tests" = x"yes"; then
113 cat stdout | grep "^${red}FAIL${std}: .*error"
115 cat stdout | grep "^${mgn}ERROR${std}: .*error"
122 # With make implementations that, like Solaris make, in case of errors
123 # print the whole failing recipe on standard output, we should content
124 # ourselves with a laxer check, to avoid false positives.
125 # Keep this in sync with lib/am/check.am:$(am__color_tests).
126 if $FGREP '= Xalways; then' stdout; then
127 # Extra verbose make, resort to laxer checks.
128 # Note that we also want to check that the testsuite summary is
129 # not unduly colorized.
131 set +e # In case some grepped regex below isn't matched.
132 # Not a useless use of cat; see above comments "grep-nonprinting"
133 # requirement in 'test-init.sh'.
134 cat stdout | grep "TOTAL.*:"
135 cat stdout | grep "PASS.*:"
136 cat stdout | grep "FAIL.*:"
137 cat stdout | grep "SKIP.*:"
138 cat stdout | grep "XFAIL.*:"
139 cat stdout | grep "XPASS.*:"
140 cat stdout | grep "ERROR.*:"
141 cat stdout | grep 'test.*expected'
142 cat stdout | grep 'test.*not run'
143 cat stdout | grep '===='
144 cat stdout | grep '[Ss]ee .*test-suite\.log'
145 cat stdout | grep '[Tt]estsuite summary'
146 ) | grep "$esc" && Exit 1
147 : For shells with broken 'set -e'
149 cat stdout | grep "$esc" && Exit 1
150 : For shells with broken 'set -e'
154 cat >expect-make <<'END'
155 eval spawn $env(MAKE) -e check
159 for vpath in false :; do
171 TERM=ansi MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
172 || { cat stdout; Exit 1; }
176 TERM=dumb MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
177 || { cat stdout; Exit 1; }
181 AM_COLOR_TESTS=no MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
182 || { cat stdout; Exit 1; }