* automake.in (handle_tests): Set COLOR depending on `color-tests'.
* configure.ac (AM_INIT_AUTOMAKE): Use `color-tests'.
* doc/automake.texi (Tests, Options): Document test results,
document new option, document AM_COLOR_TESTS.
* lib/Automake/Options.pm (_process_option_list): Handle it.
* lib/am/check.am (am__tty_colors): New variable. Enable colored
output if TERM is not dumb and depending on AM_COLOR_TESTS and
whether stdout is connected to a terminal.
(check-TESTS): Use am__tty_colors.
* NEWS: Mention color-tests.
* tests/color.test: New test.
* tests/Makefile.am: Adjust.
+2007-11-08 Akim Demaille <akim@lrde.epita.fr>
+ Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+ Bob Proulx <bob@proulx.com>
+
+ Implement colorized test output.
+ * automake.in (handle_tests): Set COLOR depending on `color-tests'.
+ * configure.ac (AM_INIT_AUTOMAKE): Use `color-tests'.
+ * doc/automake.texi (Tests, Options): Document test results,
+ document new option, document AM_COLOR_TESTS.
+ * lib/Automake/Options.pm (_process_option_list): Handle it.
+ * lib/am/check.am (am__tty_colors): New variable. Enable colored
+ output if TERM is not dumb and depending on AM_COLOR_TESTS and
+ whether stdout is connected to a terminal.
+ (check-TESTS): Use am__tty_colors.
+ * NEWS: Mention color-tests.
+ * tests/color.test: New test.
+ * tests/Makefile.am: Adjust.
+
2007-11-08 NightStrike <nightstrike@gmail.com> (tiny change)
For PR automake/526:
stub rules. This allows `make' to trigger a rerun of `aclocal'
also if some previously needed macro file has been removed.
+ - The `color-tests' option causes colored test result output on terminals.
+
Bugs fixed in 1.10a:
* Long standing bugs:
if (var ('TESTS'))
{
push (@check_tests, 'check-TESTS');
- $output_rules .= &file_contents ('check', new Automake::Location);
+ $output_rules .= &file_contents ('check', new Automake::Location,
+ COLOR => !! option 'color-tests');
# Tests that are known programs should have $(EXEEXT) appended.
# For matching purposes, we need to adjust XFAIL_TESTS as well.
# suite) without being bothered by `missing'.
AC_SUBST([am_AUTOCONF], ["${AUTOCONF-autoconf}"])
-AM_INIT_AUTOMAKE([1.8a dist-bzip2 filename-length-max=99])
+AM_INIT_AUTOMAKE([1.8a dist-bzip2 filename-length-max=99 color-tests])
# The API version is the base version. We must guarantee
# compatibility for all releases with the same API version.
, Build Directories , autoconf, The Autoconf Manual}), and in
particular for the @code{distcheck} rule (@pxref{Dist}).
+For each of the @code{TESTS}, the result of execution is printed along
+with the test name, where @code{PASS} denotes a successful test,
+@code{FAIL} denotes a failed test, @code{XFAIL} an expected failure,
+@code{XPASS} an unexpected pass for a test that is supposed to fail,
+and @code{SKIP} denotes a skipped test.
+
@cindex Exit status 77, special interpretation
The number of failures will be printed at the end of the run. If a
in the final count. This feature allows non-portable tests to be
ignored in environments where they don't make sense.
+@vindex AM_COLOR_TESTS
+If the Automake option @code{color-tests} is used (@pxref{Options})
+and standard output is connected to a capable terminal, then the test
+results and the summary are colored appropriately. The user can disable
+colored output by setting the @command{make} variable
+@samp{AM_COLOR_TESTS=no}, or force colored output even without a connecting
+terminal with @samp{AM_COLOR_TESTS=always}.
+
@vindex TESTS
@vindex TESTS_ENVIRONMENT
The variable @code{TESTS_ENVIRONMENT} can be used to set environment
Cause @samp{make dist} to fail unless the current version number appears
in the first few lines of the @file{NEWS} file.
+@item @option{color-tests}
+@cindex Option, @option{color-tests}
+@opindex color-tests
+Cause output of the simple test suite (@pxref{Tests}) to be
+colorized on capable terminals.
+
@item @option{dejagnu}
@cindex Option, @option{dejagnu}
@opindex dejagnu
|| $_ eq 'subdir-objects' || $_ eq 'nostdinc'
|| $_ eq 'no-exeext' || $_ eq 'no-define'
|| $_ eq 'std-options'
+ || $_ eq 'color-tests'
|| $_ eq 'cygnus' || $_ eq 'no-dependencies')
{
# Explicitly recognize these.
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
+# If stdout is a non-dumb tty, use colors. If test -t is not supported,
+# then this fails; a conservative approach. Of course do not redirect
+# stdout here, just stderr.
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=; \
+test "X$(AM_COLOR_TESTS)" != Xno \
+&& test "X$$TERM" != Xdumb \
+&& { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
+&& { \
+ red='\e[0;31m'; \
+ grn='\e[0;32m'; \
+ lgn='\e[1;32m'; \
+ blu='\e[1;34m'; \
+ std='\e[m'; \
+}
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
@failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
srcdir=$(srcdir); export srcdir; \
list=' $(TESTS) '; \
+ $(am__tty_colors); \
if test -n "$$list"; then \
for tst in $$list; do \
if test -f ./$$tst; then dir=./; \
*$$ws$$tst$$ws*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
- echo "XPASS: $$tst"; \
+ col=$$red; res=XPASS; \
;; \
*) \
- echo "PASS: $$tst"; \
+ col=$$grn; res=PASS; \
;; \
esac; \
elif test $$? -ne 77; then \
case " $(XFAIL_TESTS) " in \
*$$ws$$tst$$ws*) \
xfail=`expr $$xfail + 1`; \
- echo "XFAIL: $$tst"; \
+ col=$$lgn; res=XFAIL; \
;; \
*) \
failed=`expr $$failed + 1`; \
- echo "FAIL: $$tst"; \
+ col=$$red; res=FAIL; \
;; \
esac; \
else \
skip=`expr $$skip + 1`; \
- echo "SKIP: $$tst"; \
+ col=$$blu; res=SKIP; \
fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
done; \
if test "$$failed" -eq 0; then \
if test "$$xfail" -eq 0; then \
dashes="$$report"; \
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
- echo "$$dashes"; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
echo "$$banner"; \
test -z "$$skipped" || echo "$$skipped"; \
test -z "$$report" || echo "$$report"; \
- echo "$$dashes"; \
+ echo "$$dashes$$std"; \
test "$$failed" -eq 0; \
else :; fi
## automake - create Makefile.in from Makefile.am
-## Copyright (C) 2001, 2003, 2006 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2003, 2006, 2007 Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
+if %?COLOR%
+# If stdout is a non-dumb tty, use colors. If test -t is not supported,
+# then this fails; a conservative approach. Of course do not redirect
+# stdout here, just stderr.
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=; \
+test "X$(AM_COLOR_TESTS)" != Xno \
+&& test "X$$TERM" != Xdumb \
+&& { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
+&& { \
+ red='\e[0;31m'; \
+ grn='\e[0;32m'; \
+ lgn='\e[1;32m'; \
+ blu='\e[1;34m'; \
+ std='\e[m'; \
+}
+else !%?COLOR%
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+endif !%?COLOR%
+
.PHONY: check-TESTS
check-TESTS: $(TESTS)
## Make sure Solaris VPATH-expands all members of this list, even
## the first and the last one; thus the spaces around $(TESTS)
list=' $(TESTS) '; \
+ $(am__tty_colors); \
if test -n "$$list"; then \
for tst in $$list; do \
if test -f ./$$tst; then dir=./; \
*$$ws$$tst$$ws*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
- echo "XPASS: $$tst"; \
+ col=$$red; res=XPASS; \
;; \
*) \
- echo "PASS: $$tst"; \
+ col=$$grn; res=PASS; \
;; \
esac; \
elif test $$? -ne 77; then \
case " $(XFAIL_TESTS) " in \
*$$ws$$tst$$ws*) \
xfail=`expr $$xfail + 1`; \
- echo "XFAIL: $$tst"; \
+ col=$$lgn; res=XFAIL; \
;; \
*) \
failed=`expr $$failed + 1`; \
- echo "FAIL: $$tst"; \
+ col=$$red; res=FAIL; \
;; \
esac; \
else \
## Skipped
skip=`expr $$skip + 1`; \
- echo "SKIP: $$tst"; \
+ col=$$blu; res=SKIP; \
fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
done; \
## Prepare the banner
if test "$$failed" -eq 0; then \
dashes="$$report"; \
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
- echo "$$dashes"; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
echo "$$banner"; \
test -z "$$skipped" || echo "$$skipped"; \
test -z "$$report" || echo "$$report"; \
- echo "$$dashes"; \
+ echo "$$dashes$$std"; \
test "$$failed" -eq 0; \
else :; fi
colon5.test \
colon6.test \
colon7.test \
+color.test \
comment.test \
comment2.test \
comment3.test \
CONFIG_CLEAN_FILES = defs aclocal-${APIVERSION} automake-${APIVERSION}
SOURCES =
DIST_SOURCES =
+# If stdout is a non-dumb tty, use colors. If test -t is not supported,
+# then this fails; a conservative approach. Of course do not redirect
+# stdout here, just stderr.
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=; \
+test "X$(AM_COLOR_TESTS)" != Xno \
+&& test "X$$TERM" != Xdumb \
+&& { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
+&& { \
+ red='\e[0;31m'; \
+ grn='\e[0;32m'; \
+ lgn='\e[1;32m'; \
+ blu='\e[1;34m'; \
+ std='\e[m'; \
+}
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
colon5.test \
colon6.test \
colon7.test \
+color.test \
comment.test \
comment2.test \
comment3.test \
@failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
srcdir=$(srcdir); export srcdir; \
list=' $(TESTS) '; \
+ $(am__tty_colors); \
if test -n "$$list"; then \
for tst in $$list; do \
if test -f ./$$tst; then dir=./; \
*$$ws$$tst$$ws*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
- echo "XPASS: $$tst"; \
+ col=$$red; res=XPASS; \
;; \
*) \
- echo "PASS: $$tst"; \
+ col=$$grn; res=PASS; \
;; \
esac; \
elif test $$? -ne 77; then \
case " $(XFAIL_TESTS) " in \
*$$ws$$tst$$ws*) \
xfail=`expr $$xfail + 1`; \
- echo "XFAIL: $$tst"; \
+ col=$$lgn; res=XFAIL; \
;; \
*) \
failed=`expr $$failed + 1`; \
- echo "FAIL: $$tst"; \
+ col=$$red; res=FAIL; \
;; \
esac; \
else \
skip=`expr $$skip + 1`; \
- echo "SKIP: $$tst"; \
+ col=$$blu; res=SKIP; \
fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
done; \
if test "$$failed" -eq 0; then \
if test "$$xfail" -eq 0; then \
dashes="$$report"; \
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
- echo "$$dashes"; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
echo "$$banner"; \
test -z "$$skipped" || echo "$$skipped"; \
test -z "$$report" || echo "$$report"; \
- echo "$$dashes"; \
+ echo "$$dashes$$std"; \
test "$$failed" -eq 0; \
else :; fi
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test Automake TESTS color output.
+
+. ./defs || exit 1
+
+set -e
+
+red='\e[0;31m'
+grn='\e[0;32m'
+lgn='\e[1;32m'
+blu='\e[1;34m'
+std='\e[m'
+
+cat >>configure.in <<END
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = color-tests
+TESTS = $(check_SCRIPTS)
+check_SCRIPTS = pass fail skip xpass xfail
+XFAIL_TESTS = xpass xfail
+END
+
+cat >pass <<END
+#! /bin/sh
+exit 0
+END
+
+cat >fail <<END
+#! /bin/sh
+exit 1
+END
+
+cat >skip <<END
+#! /bin/sh
+exit 77
+END
+
+cp fail xfail
+cp pass xpass
+chmod +x pass fail skip xpass xfail
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+
+test_color ()
+{
+ grep ": pass" stdout | $FGREP "$grn"
+ grep ": fail" stdout | $FGREP "$red"
+ grep ": xfail" stdout | $FGREP "$lgn"
+ grep ": xpass" stdout | $FGREP "$red"
+ grep ": skip" stdout | $FGREP "$blu"
+}
+
+test_no_color ()
+{
+ grep ": pass" stdout | $FGREP "$grn" && exit 1
+ grep ": fail" stdout | $FGREP "$red" && exit 1
+ grep ": xfail" stdout | $FGREP "$lgn" && exit 1
+ grep ": xpass" stdout | $FGREP "$red" && exit 1
+ grep ": skip" stdout | $FGREP "$blu" && exit 1
+ :
+}
+
+cat >expect-make <<'END'
+#! /usr/bin/expect -f
+spawn $env(MAKE) check $argv
+expect eof
+END
+
+$MAKE check AM_COLOR_TESTS=always >stdout && { cat stdout; exit 1; }
+cat stdout
+test_color
+
+MAKE=$MAKE expect -f expect-make foo= >stdout || exit 77
+cat stdout
+test_color
+
+MAKE=$MAKE expect -f expect-make AM_COLOR_TESTS=no >stdout || exit 77
+cat stdout
+test_no_color
+: