Subject: bug#8969: improve synchronization between examples in the manual and test cases

From: Stefano Lattarini <[email-masked]>
Date: Wed, 6 Jul 2011 10:32:56 +0200

On Wednesday 06 July 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Fri, Jul 01, 2011 at 12:59:53AM CEST:
> > Subject: [PATCH] docs, tests: synchronize examples from docs to tests
> > 
> > * tests/README (Writing test cases): Give suggestions on how to
> > keep test cases and examples in the documentation synchronized.
> > * doc/automake.texi: Improve or fix existing testcase-referencing
> > comments, and add many new ones.
> > * HACKING (Administrivia): Suggest to test complex examples and
> > idioms from the manual.
> > * tests/specflg8.test: Improve synchronization with the example
> > in the manual.
> > * tests/output11.test:Likewise.
> > * tests/txinfo21.test:Likewise.
> > * tests/interp.test: Likewise.  Since we are at it, and enable
> > the `errexit' shell flag, do related changes, and add trailing
> > `:'command.
> > * tests/amhello-cflags.test: New test.
> > * tests/amhello-cross-compile.test: Likewise.
> > * tests/amhello-binpkg.test: Likewise.
> > * tests/tests-environment-backcompat: Likewise.
> > * tests/parallel-tests-log-compiler-example.test: Likewise.
> > * tests/Makefile.am (TESTS): Update.
> 
> 
> > --- /dev/null
> > +++ b/tests/amhello-binpkg.test
> > @@ -0,0 +1,44 @@
> 
> > +# Document an example from the manual about the `amhello' package:
> > +# using DESDIR to build simple, no-frills binary packages.
> 
> (DESTDIR was already fixed IIUC)
> 
> > +required=i586-mingw32msvc-gcc
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +cp "$testsrcdir"/../doc/amhello-1.0.tar.gz . \
> > +  || fatal_ "cannot get amhello tarball"
> > +
> > +tar zxf amhello-1.0.tar.gz
> 
> The z flag is not portable to all tars, the portable spelling is
>   gzip -dc amhello-1.0.tar.gz | tar xf -
> 
> (several instances).
>
Oops, sorry.  Fixed by the attached patch.  OK for maint?  I'll wait
the customary 72 hours before pushing.

> I'm ok with fixing the manual also, although it's
> usually clear for people still having to use those vendor tars (and
> inconvenient for the rest).
>
Yes, I'd say we leave the examples in manual untouched.  Agreed?

> > +cd amhello-1.0
> > +
> > +./configure --prefix /usr
> > +make
> > +make DESTDIR="`pwd`/inst" install
> > +cd inst
> > +find . -type f -print > ../files.lst
> > +tar cvf amhello-1.0-i686.tar.gz `cat ../files.lst` > t
> > +LC_ALL=C sort t > tar.got
> > +
> > +diff - tar.got <<'END'
> > +./usr/bin/hello
> > +./usr/share/doc/amhello/README
> > +END
> [...]
> 
> Nice patch btw!
>
Thanks :-)

Regards,
  Stefano
From d7e03b029b3ae322ed719ef501810d7334eaf288 Mon Sep 17 00:00:00 2001
Message-Id: <d7e03b029[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Wed, 6 Jul 2011 10:31:03 +0200
Subject: [PATCH] tests: portability fixes in tests on amhello examples

* tests/amhello-binpkg.test: Don't use "tar xzf too.tag.gz" to
extract a gzip-compressed tarball, that's unportable to some
tar implementations; use the "gzip -dc fo.tar.gz | tar xf -"
idiom instead.
* tests/amhello-cflags.test: Likewise.
* tests/amhello-cross-compile.test: Likewise.

Suggestion from Ralf Wildenhues.
---
 ChangeLog                        |   11 +++++++++++
 tests/amhello-binpkg.test        |    3 ++-
 tests/amhello-cflags.test        |    4 +++-
 tests/amhello-cross-compile.test |    3 ++-
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c77326d..c6f8d05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-07-06  Stefano Lattarini  <[email-masked]>
+
+	tests: portability fixes in tests on amhello examples
+	* tests/amhello-binpkg.test: Don't use "tar xzf too.tag.gz" to
+	extract a gzip-compressed tarball, that's unportable to some
+	tar implementations; use the "gzip -dc fo.tar.gz | tar xf -"
+	idiom instead.
+	* tests/amhello-cflags.test: Likewise.
+	* tests/amhello-cross-compile.test: Likewise.
+	Suggestion from Ralf Wildenhues.
+
 2011-07-01  Stefano Lattarini  <[email-masked]>
 
 	docs, tests: synchronize examples from docs to tests
diff --git a/tests/amhello-binpkg.test b/tests/amhello-binpkg.test
index 8085a23..951f713 100755
--- a/tests/amhello-binpkg.test
+++ b/tests/amhello-binpkg.test
@@ -24,7 +24,8 @@ set -e
 cp "$testsrcdir"/../doc/amhello-1.0.tar.gz . \
   || fatal_ "cannot get amhello tarball"
 
-tar zxf amhello-1.0.tar.gz
+# "tar zxf" in unportable to some tar implementations.
+gzip -dc amhello-1.0.tar.gz | tar xf -
 cd amhello-1.0
 
 ./configure --prefix /usr
diff --git a/tests/amhello-cflags.test b/tests/amhello-cflags.test
index 1c3e516..25b0a52 100755
--- a/tests/amhello-cflags.test
+++ b/tests/amhello-cflags.test
@@ -26,8 +26,10 @@ set -e
 cp "$testsrcdir"/../doc/amhello-1.0.tar.gz . \
   || fatal_ "cannot get amhello tarball"
 
-tar zxf amhello-1.0.tar.gz
+# "tar zxf" in unportable to some tar implementations.
+gzip -dc amhello-1.0.tar.gz | tar xf -
 cd amhello-1.0
+
 mkdir debug optim
 cd debug
 ../configure CFLAGS='-g -O0'
diff --git a/tests/amhello-cross-compile.test b/tests/amhello-cross-compile.test
index 862a079..7c05fc0 100755
--- a/tests/amhello-cross-compile.test
+++ b/tests/amhello-cross-compile.test
@@ -30,7 +30,8 @@ build=`"$testsrcdir"/../lib/config.guess` && test -n "$build" \
   || fatal_ "cannot guess build platform"
 case $build in *mingw*) skip_ "build system is MinGW too";; esac
 
-tar zxf amhello-1.0.tar.gz
+# "tar zxf" in unportable to some tar implementations.
+gzip -dc amhello-1.0.tar.gz | tar xf -
 cd amhello-1.0
 
 ./configure --build "$build" --host "$host" > stdout \
-- 
1.7.2.3