diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-04-06 13:12:25 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-04-06 21:29:30 +0200 |
commit | 8a5096d150cf9803b8963768b7366cd68edcce03 (patch) | |
tree | a49c0e54876b8b9877d7ca2df386377e7b6037d1 /t/color2.sh | |
parent | f8e822bbc197f01fc722aa6def7cddb4182e3c66 (diff) | |
download | automake-8a5096d150cf9803b8963768b7366cd68edcce03.tar.gz |
tests: rename 'tests/' => 't/', '*.test' => '*.sh'
When we (soon) convert the Automake testsuite to a non-recursive
make setup, we'll have to fix the entries of $(TESTS) to be
prepended with the subdirectory they are in; this will increase
the length of $(TESTS), and thus increase the possibility of
exceeding the command-line length limits on some systems (most
notably, MinGW/MSYS). See automake bug#7868 for more information.
Thus we rename the 'tests/' subdirectory to 't/', and each 'x.test'
script in there to 'x.sh'; this way, the $(TESTS) entry 'foo.test'
will become 't/foo.sh', which have the same number of characters.
* tests/: Rename ...
* t/: ... to this.
* t/*.test: Rename ...
* t/*.sh: ... to this.
* t/.gitignore: Removed as obsolete.
* t/defs: Adjust.
* t/gen-testsuite-part: Likewise.
* t/list-of-tests.mk: Likewise.
* t/ccnoco.sh: Likewise.
* t/ccnoco3.sh: Likewise.
* t/self-check-cleanup.tap: Likewise.
* t/self-check-dir.tap: Likewise.
* t/self-check-me.tap: Likewise.
* t/self-check-reexec.tap: Likewise.
* README: Likewise.
* bootstrap: Likewise
* configure.ac: Likewise.
* Makefile.am: Likewise.
* .gitignore: Likewise.
* syntax-check.mk: Likewise.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/color2.sh')
-rwxr-xr-x | t/color2.sh | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/t/color2.sh b/t/color2.sh new file mode 100755 index 000000000..b1c8830ee --- /dev/null +++ b/t/color2.sh @@ -0,0 +1,194 @@ +#! /bin/sh +# Copyright (C) 2007-2012 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +# Test Automake TESTS color output, using the expect(1) program. +# Keep this in sync with the sister test 'color.test'. + +. ./defs || Exit 1 + +TERM=ansi +export TERM + +esc='' +# Escape '[' for grep, below. +red="$esc\[0;31m" +grn="$esc\[0;32m" +lgn="$esc\[1;32m" +blu="$esc\[1;34m" +mgn="$esc\[0;35m" +std="$esc\[m" + +# Check that grep can parse nonprinting characters. +# BSD 'grep' works from a pipe, but not a seekable file. +# GNU or BSD 'grep -a' works on files, but is not portable. +case `echo "$std" | grep .` in + "$std") ;; + *) skip_ "grep can't parse nonprinting characters";; +esac + +# This test requires a working a working 'expect' program. +# Creative quoting required to avoid spurious maintainer-check failure. +(set +e; expect -c 'exit ''77'; test $? -eq 77) \ + || skip_ "requires a working expect program" + +# Also, if the $MAKE program fails to consider the standard output as a +# tty (this happens with e.g., BSD make and Solaris dmake when they're +# run in parallel mode; see the autoconf manual), there is little point +# in proceeding. +cat > Makefile <<'END' +all: +## Creative quoting in the 'echo' below to avoid risk of spurious output +## matches by 'expect', below. + @test -t 1 && echo "stdout" "is" "a" "tty" +END + +cat > expect-check <<'END' +eval spawn $env(MAKE) +expect { + "stdout is a tty" { exit 0 } + default { exit 1 } +} +exit 1 +END +MAKE=$MAKE expect -f expect-check \ + || skip_ "make spawned by expect should have a tty stdout" +rm -f expect-check Makefile + +# Do the tests. + +cat >>configure.ac <<END +AC_OUTPUT +END + +cat >Makefile.am <<'END' +AUTOMAKE_OPTIONS = color-tests +TESTS = $(check_SCRIPTS) +check_SCRIPTS = pass fail skip xpass xfail error +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 + +cat >error <<END +#! /bin/sh +exit 99 +END + +cp fail xfail +cp pass xpass +chmod +x pass fail skip xpass xfail error + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --add-missing + +test_color () +{ + # Not a useless use of cat; see above comments about grep. + cat stdout | grep "^${grn}PASS${std}: .*pass" + cat stdout | grep "^${red}FAIL${std}: .*fail" + cat stdout | grep "^${blu}SKIP${std}: .*skip" + cat stdout | grep "^${lgn}XFAIL${std}: .*xfail" + cat stdout | grep "^${red}XPASS${std}: .*xpass" + # The old serial testsuite driver doesn't distinguish between failures + # and hard errors. + if test x"$am_parallel_tests" = x"yes"; then + cat stdout | grep "^${mgn}ERROR${std}: .*error" + else + cat stdout | grep "^${red}FAIL${std}: .*error" + fi + : +} + +test_no_color () +{ + # With make implementations that, like Solaris make, in case of errors + # print the whole failing recipe on standard output, we should content + # ourselves with a laxer check, to avoid false positives. + # Keep this in sync with lib/am/check.am:$(am__color_tests). + if $FGREP '= Xalways || test -t 1 ' stdout; then + # Extra verbose make, resort to laxer checks. + # Note that we also want to check that the testsuite summary is + # not unduly colorized. + ( + set +e # In case some grepped regex below isn't matched. + # Not a useless use of cat; see above comments about grep. + cat stdout | grep "TOTAL.*:" + cat stdout | grep "PASS.*:" + cat stdout | grep "FAIL.*:" + cat stdout | grep "SKIP.*:" + cat stdout | grep "XFAIL.*:" + cat stdout | grep "XPASS.*:" + cat stdout | grep "ERROR.*:" + cat stdout | grep 'test.*expected' + cat stdout | grep 'test.*not run' + cat stdout | grep '====' + cat stdout | grep '[Ss]ee .*test-suite\.log' + cat stdout | grep '[Tt]estsuite summary' + ) | grep "$esc" && Exit 1 + : For shells with broken 'set -e' + else + cat stdout | grep "$esc" && Exit 1 + : For shells with broken 'set -e' + fi +} + +cat >expect-make <<'END' +eval spawn $env(MAKE) -e check +expect eof +END + +for vpath in false :; do + + if $vpath; then + mkdir build + cd build + srcdir=.. + else + srcdir=. + fi + + $srcdir/configure + + MAKE=$MAKE expect -f $srcdir/expect-make >stdout \ + || { cat stdout; Exit 1; } + cat stdout + test_color + + AM_COLOR_TESTS=no MAKE=$MAKE expect -f $srcdir/expect-make >stdout \ + || { cat stdout; Exit 1; } + cat stdout + test_no_color + + $MAKE distclean + cd $srcdir + +done + +: |