Silence successful tests that use 'compare' on AIX, HP-UX, Solaris.
authorBruno Haible <bruno@clisp.org>
Sun, 13 Nov 2011 20:20:59 +0000 (21:20 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 13 Nov 2011 20:21:34 +0000 (21:21 +0100)
* tests/init.sh (compare): Remove "No differences encountered" or
synonymous output from the 'diff' program.

ChangeLog
tests/init.sh

index 59f84c4..962b2c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
 2011-11-13  Bruno Haible  <bruno@clisp.org>
+           Jim Meyering  <meyering@redhat.com>
+
+       Silence successful tests that use 'compare' on AIX, HP-UX, Solaris.
+       * tests/init.sh (compare): Remove "No differences encountered" or
+       synonymous output from the 'diff' program.
+
+2011-11-13  Bruno Haible  <bruno@clisp.org>
 
        Makefile: Tweak indentation.
        * Makefile: Use tab as first character in every line that contains rule
index 373d9d4..c78e5b6 100644 (file)
@@ -221,10 +221,43 @@ export MALLOC_PERTURB_
 # a partition, or to undo any other global state changes.
 cleanup_ () { :; }
 
-if ( diff -u "$0" "$0" < /dev/null ) > /dev/null 2>&1; then
-  compare () { diff -u "$@"; }
-elif ( diff -c "$0" "$0" < /dev/null ) > /dev/null 2>&1; then
-  compare () { diff -c "$@"; }
+if diff_out_=`( diff -u "$0" "$0" < /dev/null ) 2>/dev/null`; then
+  if test -z "$diff_out_"; then
+    compare () { diff -u "$@"; }
+  else
+    compare ()
+    {
+      if diff -u "$@" > diff.out; then
+        # No differences were found, but Solaris 'diff' produces output
+        # "No differences encountered". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
+elif diff_out_=`( diff -c "$0" "$0" < /dev/null ) 2>/dev/null`; then
+  if test -z "$diff_out_"; then
+    compare () { diff -c "$@"; }
+  else
+    compare ()
+    {
+      if diff -c "$@" > diff.out; then
+        # No differences were found, but AIX and HP-UX 'diff' produce output
+        # "No differences encountered" or "There are no differences between the
+        # files.". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
 elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
   compare () { cmp -s "$@"; }
 else