* t/ax/test-inist.sh ($esc): New, a literal escape character.
(grep-nonprint): New requirement, check that the grep implementation
available that can handle non-printing characters correctly.
* t/color.sh: Use it instead of hand-rolled equivalent, and do not
(re)define '$esc' explicitly.
* t/color2.sh: Likewise.
* t/tap-color.sh: Likewise.
* t/vtexi4.sh: Likewise.
* t/parallel-tests-no-color-in-log.sh: Likewise. Also prefer the use
of grep over that of $FGREP, because the new requirement only check
grep, and ensure we only grep non-printing characters from a pipe, to
avoid hitting a BSD grep limitation.
* t/parallel-tests-reset-term.sh: Likewise.
* t/ax/tap-summary-aux.sh: Use '$esc' instead of hard-coding the
literal escape character.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
}
if test $use_colors = yes; then
- red='\e[0;31m'
- grn='\e[0;32m'
- lgn='\e[1;32m'
- blu='\e[1;34m'
- mgn='\e[0;35m'
- brg='\e[1m'
- std='\e[m'
+ red="$esc[0;31m"
+ grn="$esc[0;32m"
+ lgn="$esc[1;32m"
+ blu="$esc[1;34m"
+ mgn="$esc[0;35m"
+ brg="$esc[1m"
+ std="$esc[m"
echo AUTOMAKE_OPTIONS = color-tests >> Makefile.am
else
red= grn= lgn= blu= mgn= brg= std=
# A newline character.
nl='
'
+# A literal escape character. Used by test checking colored output.
+esc='\e'
# As autoconf-generated configure scripts do, ensure that IFS
# is defined initially, so that saving and restoring $IFS works.
*) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;;
esac
;;
+ grep-nonprint)
+ # Check that grep can parse nonprinting characters correctly.
+ # 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 "$esc" | grep .)$(echo "$esc" | grep "$esc") in
+ "$esc$esc") ;;
+ *) skip_ "grep can't handle nonprinting characters correctly";;
+ esac
+ ;;
javac)
# The Java compiler from JDK 1.5 (and presumably earlier versions)
# cannot handle the '-version' option by itself: it bails out
# Test Automake TESTS color output, by forcing it.
# Keep this in sync with the sister test 'color2.test'.
+required='grep-nonprint'
# For gen-testsuite-part: ==> try-with-serial-tests <==
. ./defs || Exit 1
-esc='\e'
# Escape '[' for grep, below.
red="$esc\[0;31m"
grn="$esc\[0;32m"
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
-
cat >>configure.ac <<END
AC_OUTPUT
END
test_color ()
{
- # Not a useless use of cat; see above comments about grep.
+ # Not a useless use of cat; see above comments "grep-nonprinting"
+ # requirement in 'test-init.sh'.
cat stdout | grep "^${grn}PASS${std}: .*pass"
cat stdout | grep "^${red}FAIL${std}: .*fail"
cat stdout | grep "^${blu}SKIP${std}: .*skip"
# 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.
+ # Not a useless use of cat; see above comments "grep-nonprinting"
+ # requirement in 'test-init.sh'.
cat stdout | grep "TOTAL.*:"
cat stdout | grep "PASS.*:"
cat stdout | grep "FAIL.*:"
# Test Automake TESTS color output, using the expect(1) program.
# Keep this in sync with the sister test 'color.test'.
+required='grep-nonprint'
# For gen-testsuite-part: ==> try-with-serial-tests <==
. ./defs || Exit 1
-esc='\e'
# Escape '[' for grep, below.
red="$esc\[0;31m"
grn="$esc\[0;32m"
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) \
test_color ()
{
- # Not a useless use of cat; see above comments about grep.
+ # Not a useless use of cat; see above comments "grep-nonprinting"
+ # requirement in 'test-init.sh'.
cat stdout | grep "^${grn}PASS${std}: .*pass"
cat stdout | grep "^${red}FAIL${std}: .*fail"
cat stdout | grep "^${blu}SKIP${std}: .*skip"
# 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.
+ # Not a useless use of cat; see above comments "grep-nonprinting"
+ # requirement in 'test-init.sh'.
cat stdout | grep "TOTAL.*:"
cat stdout | grep "PASS.*:"
cat stdout | grep "FAIL.*:"
# Colorized output from the testsuite report shouldn't end up in log files.
+required='grep-nonprint'
. ./defs || Exit 1
-esc='\e'
-
-# 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 "$esc" | $FGREP "$esc"` in
- "$esc") ;;
-# Creative quoting below to please maintainer-check.
- *) echo "$me: f""grep can't parse nonprinting characters" >&2; Exit 77;;
-esac
-
TERM=ansi; export TERM
cat >>configure.ac <<END
./configure
mv config.log config-log # Avoid possible false positives below.
AM_COLOR_TESTS=always $MAKE -e check && Exit 1
-$FGREP "$esc" *.log && Exit 1
+# Not a useless use of cat; see above comments "grep-nonprinting"
+# requirement in 'test-init.sh'.
+cat *.log | grep "$esc" && Exit 1
:
# Check that the parallel-tests driver correctly handle overrides of the
# TERM variable by either TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
+required='grep-nonprint'
. ./defs || Exit 1
-esc='\e['
-
TERM=ansi; export TERM
-# 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 "$esc" | $FGREP "$esc"` in
- "$esc") ;;
- *) skip_ "$FGREP can't parse nonprinting characters" ;;
-esac
-
cat >> configure.ac << 'END'
AC_OUTPUT
END
./configure
mkcheck TESTS_ENVIRONMENT='TERM=dumb'
-cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
+cat stdout | grep "PASS.*foobar" | grep "$esc\\["
mkcheck AM_TESTS_ENVIRONMENT='TERM=dumb'
-cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
+cat stdout | grep "PASS.*foobar" | grep "$esc\\["
:
# TAP support:
# - colorization of TAP results and diagnostic messages
+required='grep-nonprint'
. ./defs || Exit 1
-esc='\e'
# Escape '[' for grep, below.
red="$esc\[0;31m"
grn="$esc\[0;32m"
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") ;;
- *) echo "$me: grep can't parse nonprinting characters" >&2; Exit 77;;
-esac
-
cat > Makefile.am << 'END'
AUTOMAKE_OPTIONS = color-tests
AM_TEST_LOG_DRIVER_FLAGS = --comments
test_color ()
{
- # Not a useless use of cat; see above comments about grep.
+ # Not a useless use of cat; see above comments "grep-nonprinting"
+ # requirement in 'test-init.sh'.
cat stdout | grep "^${grn}PASS${std}: all\.test 1 - foo$"
cat stdout | grep "^${lgn}XFAIL${std}: all\.test 2 - bar # TODO td$"
cat stdout | grep "^${blu}SKIP${std}: all\.test 3 - baz # SKIP sk$"
# colorized.
(
set +e # In case some grepped regex below isn't matched.
- # Not a useless use of cat; see above comments about grep.
+ # Not a useless use of cat; see above comments "grep-nonprinting"
+ # requirement in 'test-init.sh'.
cat stdout | grep "TOTAL.*:"
cat stdout | grep "PASS.*:"
cat stdout | grep "FAIL.*:"
# for more vers*.texi files, and does not require makeinfo, tex and
# texi2dvi.
-required='makeinfo tex texi2dvi-o'
+required='makeinfo tex texi2dvi-o grep-nonprint'
. ./defs || Exit 1
test $(LC_ALL=C date '+%u') -gt 0 && test $(LC_ALL=C date '+%u') -lt 8 \
|| skip_ "'date' is not POSIX-compliant enough"
day=$(echo "$day" | sed 's/^0//')
-(echo '\ex\a' | grep x) \
- || skip_ "grep doesn't work on input that is not pure text"
-
cat > configure.ac << END
AC_INIT([$me], [123.456])
AM_INIT_AUTOMAKE
include defs.am
info_TEXINFOS = foo.texi
test-grepinfo:
-## Not useless uses of cat: we only tested that grep worked on
+## Not useless uses of cat: we only tested that grep works on
## non-text input when that's given from a pipe.
cat $(srcdir)/foo.info | grep 'GREPVERSION=$(my_version_rx)='
cat $(srcdir)/foo.info | grep 'GREPEDITION=$(my_version_rx)='