]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Fix color.test when using BSD grep.
authorEric Blake <ebb9@byu.net>
Wed, 23 Jan 2008 17:03:58 +0000 (10:03 -0700)
committerEric Blake <ebb9@byu.net>
Wed, 23 Jan 2008 22:25:04 +0000 (15:25 -0700)
* tests/color.test: Ensure that grep can handle non-printing
characters.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
tests/color.test

index 605dd9233498ba0369e634eb90280300da717841..649e9ac7b8dc614015434440db660279c7c3d63c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-23  Eric Blake  <ebb9@byu.net>
+
+       Fix color.test when using BSD grep.
+       * tests/color.test: Ensure that grep can handle non-printing
+       characters.
+
 2008-01-23  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * tests/lisp3.test: Fix typo.
index 5b51287a6f6217a15f70ba1ac13470ac031fe86e..dd4ded59006fe1e308f29484b8ea4aa7c631220f 100755 (executable)
@@ -29,6 +29,14 @@ lgn='\e[1;32m'
 blu='\e[1;34m'
 std='\e[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) ;;
+  *) exit 77 ;;
+esac
+
 cat >>configure.in <<END
 AC_OUTPUT
 END
@@ -66,20 +74,22 @@ $AUTOCONF
 
 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"
+  # Not a useless use of cat; see above comments about grep.
+  cat stdout | grep ": pass" | $FGREP "$grn"
+  cat stdout | grep ": fail" | $FGREP "$red"
+  cat stdout | grep ": xfail" | $FGREP "$lgn"
+  cat stdout | grep ": xpass" | $FGREP "$red"
+  cat stdout | grep ": skip" | $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
+  # Not a useless use of cat; see above comments about grep.
+  cat stdout | grep ": pass" | $FGREP "$grn" && exit 1
+  cat stdout | grep ": fail" | $FGREP "$red" && exit 1
+  cat stdout | grep ": xfail" | $FGREP "$lgn" && exit 1
+  cat stdout | grep ": xpass" | $FGREP "$red" && exit 1
+  cat stdout | grep ": skip" | $FGREP "$blu" && exit 1
   :
 }