tests: new requirement 'grep-nonprint'
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 22 Jun 2012 20:31:35 +0000 (22:31 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 22 Jun 2012 20:31:56 +0000 (22:31 +0200)
* 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>
t/ax/tap-summary-aux.sh
t/ax/test-init.sh
t/color.sh
t/color2.sh
t/parallel-tests-no-color-in-log.sh
t/parallel-tests-reset-term.sh
t/tap-color.sh
t/vtexi4.sh

index 2fadb3d..8962326 100644 (file)
@@ -82,13 +82,13 @@ do_check ()
 }
 
 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=
index 01d4584..ca606b5 100644 (file)
@@ -63,6 +63,8 @@ tab=' '
 # 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.
@@ -754,6 +756,15 @@ do
         *) 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
index 18c6e23..5726ac1 100755 (executable)
 # 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"
@@ -29,14 +29,6 @@ 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
-
 cat >>configure.ac <<END
 AC_OUTPUT
 END
@@ -78,7 +70,8 @@ $AUTOMAKE --add-missing
 
 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"
@@ -106,7 +99,8 @@ test_no_color ()
     # 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.*:"
index 041ffe6..72087a0 100755 (executable)
 # 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"
@@ -29,14 +29,6 @@ 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) \
@@ -108,7 +100,8 @@ $AUTOMAKE --add-missing
 
 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"
@@ -136,7 +129,8 @@ test_no_color ()
     # 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.*:"
index 69414f7..e8e2030 100755 (executable)
 
 # 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
@@ -57,6 +47,8 @@ $AUTOMAKE --add-missing
 ./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
 
 :
index cf9fb6c..9335d61 100755 (executable)
 # 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
@@ -67,9 +58,9 @@ $AUTOMAKE -a
 ./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\\["
 
 :
index 6a91f06..5a8e1bc 100755 (executable)
@@ -17,9 +17,9 @@
 # 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"
@@ -28,14 +28,6 @@ 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") ;;
-  *) 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
@@ -101,7 +93,8 @@ 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}: 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$"
@@ -134,7 +127,8 @@ test_no_color ()
     # 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.*:"
index 27b0636..dcdcf85 100755 (executable)
@@ -21,7 +21,7 @@
 # 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 \
@@ -31,9 +31,6 @@ 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
@@ -51,7 +48,7 @@ cat > Makefile.am << 'END'
 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)='