Hi Gavin,

> > + findprog zdiff
> > + zdiff ../../../install-info/tests/ii-0041-expected-dir-file.gz 
> > /tmp/haible015772.gz
> > Warning : missing newline at end of file 
> > ../../../install-info/tests/ii-0041-expected-dir-file.gz
> > Warning : missing newline at end of file /tmp/haible015772.gz
> > 1c1
> > <`�oG
> > ---
> > > �
> > + retval=1
> 
> Indeed, I looked at a hex dump of ii-0041-expected-dir-file.gz and "oG" 
> is near the start of the file.  It's not comparing the uncompressed 
> files properly.  Maybe the HP-UX zdiff doesn't support gzip format.
> ...
> * Bundle zdiff with texinfo
> * Avoid using zdiff and replicate its functionality in the test scripts using
>   more standard tools.
> * Check whether zdiff works as expected and skip the test if it doesn't.  This
>   would be easier than the previous two options.
> 
> Does the default zdiff with HPUX have a --version output that we could check?

$ zdiff --version
Usage: zdiff [diff_options] file [file]

I prefer the "avoid using zdiff" approach, because I find it better to
execute a test when possible rather than to skip it.

Patch attached. With it, all tests in this directory pass.

Bruno
>From 4f8f09747d1664a9a61f7dcbfcddc6882ef401fd Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sun, 20 Jan 2019 13:37:54 +0100
Subject: [PATCH] Fix test failures on HP-UX.

Reported by Richard Lloyd in
<https://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.

* install-info/tests/ii-0041-test: Simulate zdiff.
* install-info/tests/ii-0050-test: Likewise.
---
 ChangeLog                       | 10 ++++++++++
 install-info/tests/ii-0041-test | 24 +++++++++++++++++++-----
 install-info/tests/ii-0050-test | 24 +++++++++++++++++++-----
 3 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0b0a399..43b7367 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-01-20  Bruno Haible  <[email protected]>
+
+	Fix test failures on HP-UX.
+
+	Reported by Richard Lloyd in
+	<https://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
+
+	* install-info/tests/ii-0041-test: Simulate zdiff.
+	* install-info/tests/ii-0050-test: Likewise.
+
 2019-01-20  Gavin Smith  <[email protected]>
 
 	Check for gawk version for rebuilding texindex.awk.
diff --git a/install-info/tests/ii-0041-test b/install-info/tests/ii-0041-test
index f7e9118..d356e00 100755
--- a/install-info/tests/ii-0041-test
+++ b/install-info/tests/ii-0041-test
@@ -18,12 +18,26 @@ chmod u+rw $outputdirfile || exit $?
 
 ${install_info} ${testdir}/ii-0041-input-info-file $outputdirfile || exit $?
 
-if findprog zdiff; then
-  zdiff ${testdir}/ii-0041-expected-dir-file.gz $outputdirfile
-  retval=$?
+# Simulate 'zdiff'. zdiff on HP-UX does not support the gzip format.
+expectedfile=${testdir}/ii-0041-expected-dir-file.gz
+expectedfile_uncompressed=$tempfile.exp
+outputdirfile_uncompressed=$tempfile.act
+if cmp $expectedfile $outputdirfile >/dev/null; then
+  retval=0
 else
-  retval=77
+  if gzip -d -c < $expectedfile > $expectedfile_uncompressed; then
+    if gzip -d -c < $outputdirfile > $outputdirfile_uncompressed; then
+      diff $expectedfile_uncompressed $outputdirfile_uncompressed
+      retval=$?
+    else
+      # $outputdirfile is not in gzip format
+      retval=1
+    fi
+  else
+    # gzip not found or not working
+    retval=77
+  fi
 fi
 
-rm -f $tempfile $outputdirfile
+rm -f $tempfile $outputdirfile $expectedfile_uncompressed $outputdirfile_uncompressed
 exit $retval
diff --git a/install-info/tests/ii-0050-test b/install-info/tests/ii-0050-test
index 48fff5a..a86e281 100755
--- a/install-info/tests/ii-0050-test
+++ b/install-info/tests/ii-0050-test
@@ -19,12 +19,26 @@ chmod u+rw $outputdirfile || exit $?
 ${install_info} --remove ${testdir}/ii-0050-input-info-file $outputdirfile \
 || exit $?
 
-if findprog zdiff; then
-  zdiff ${testdir}/ii-0050-expected-dir-file.gz $outputdirfile
-  retval=$?
+# Simulate 'zdiff'. zdiff on HP-UX does not support the gzip format.
+expectedfile=${testdir}/ii-0050-expected-dir-file.gz
+expectedfile_uncompressed=$tempfile.exp
+outputdirfile_uncompressed=$tempfile.act
+if cmp $expectedfile $outputdirfile >/dev/null; then
+  retval=0
 else
-  retval=77
+  if gzip -d -c < $expectedfile > $expectedfile_uncompressed; then
+    if gzip -d -c < $outputdirfile > $outputdirfile_uncompressed; then
+      diff $expectedfile_uncompressed $outputdirfile_uncompressed
+      retval=$?
+    else
+      # $outputdirfile is not in gzip format
+      retval=1
+    fi
+  else
+    # gzip not found or not working
+    retval=77
+  fi
 fi
 
-rm -f $tempfile $outputdirfile
+rm -f $tempfile $outputdirfile $expectedfile_uncompressed $outputdirfile_uncompressed
 exit $retval
-- 
2.7.4

Reply via email to