changeset 16087:c7f91e785206

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.
author Bruno Haible <bruno@clisp.org>
date Sun, 13 Nov 2011 21:20:59 +0100
parents a018273bd5a8
children 780e83599399
files ChangeLog tests/init.sh
diffstat 2 files changed, 44 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -221,10 +221,43 @@
 # 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