Hello automakers.

Finally, here is the patch that moves the setting of the `errexit'
shell flag in the `tests/defs' script.

Here are the steps I followed to write the patch:

 [1] I got the list of non-generated test scripts:
      $ tests=`grep -L '^#.* GENERATED AUTOMATICALLY' tests/*.test`

 [2] I checked that each of those test scripts had *one only* occurence
     of a `set -e' line, and that this line occurred immediately after
     the inclusion the `./defs' script:
       $ perl set-e.pl $tests
     (see attachement for the set-e.pl script)

 [3] I used GNU sed to remove that `set -e' line and the single following
     blank line (if any) for each of those scripts:
      $ sed -i '/^set -e$/{ N; /^set -e\n *$/d; s/^set -e\n//; }' $tests

 [4] I updated files ChangeLog, tests/defs and tests/README by hand.

The patch is attached (compressed, as it's pretty big and repetitive).
Inline below are the most relevant hunks.

I will push in 72 hours (to master) if there are no objections.

Regards,
   Stefano

-*-*-

tests: enable 'errexit' shell flag by default.

* tests/defs: Enable `errexit' shell flag (near the end).
Removed redundant comment about the enabling of shell traces.
* tests/README (Writing test cases): Update, and use nicer
formatting in a couple of places.
* All tests: Adjusted by removing now-redundant calls to
'set -e'.
---
 ChangeLog                                  |   10 ++++++++++
 tests/README                               |   25 ++++++++++++++-----------
 tests/acloca10.test                        |    2 --
 tests/acloca11.test                        |    2 --
 tests/acloca12.test                        |    2 --
 ...
 tests/yflags-var-expand.test               |    2 --
 tests/yflags.test                          |    2 --
 tests/yflags2.test                         |    2 --
 876 files changed, 25 insertions(+), 1757 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c5a8f4..be66897 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-01-08   Stefano Lattarini  <stefano.lattar...@gmail.com>
+
+       tests: enable 'errexit' shell flag by default.
+       * tests/defs: Enable `errexit' shell flag (near the end).
+       Removed redundant comment about the enabling of shell traces.
+       * tests/README (Writing test cases): Update, and use nicer
+       formatting in a couple of places.
+       * All tests: Adjusted by removing now-redundant calls to
+       'set -e'.
+
 2011-01-09  Peter Rosin  <p...@lysator.liu.se>
 
        Fix another typo in Rule.pm comment.

diff --git a/tests/README b/tests/README
index 1369bd3..2d80236 100644
--- a/tests/README
+++ b/tests/README
@@ -131,14 +131,18 @@ Do
   but do not output anything by default.  If you need ./configure
   to create Makefile, append AC_OUTPUT to configure.in.
 
-  Use `set -e' to catch failures you might not have thought of.
+  By default, the testcases are run with the `errexit' shell flag on,
+  to make it easier to catch failures you might not have thought of.
+  If  this is undesirable in some testcase, you can use `set +e' to
+  disable the `errexit' flag (but please do so only if you have a
+  very good reason).
 
   End the test script with a `:' or `Exit 0'.  Otherwise, when somebody
   changes the test by adding a failing command after the last command,
-  the test will spuriously fail because $? is nonzero at the end.
-  Note that this is relevant also for tests using `set -e', if they
-  contain commands like "grep ... Makefile.in && Exit 1" (and there
-  are indeed a lot of such tests).
+  the test will spuriously fail because $? is nonzero at the end.  Note
+  that this is relevant even if the `errexit' shell flag is on, in case
+  the test contains commands like "grep ... Makefile.in && Exit 1" (and
+  there are indeed a lot of such tests).
 
   Use $ACLOCAL, $AUTOMAKE, $AUTOCONF, $AUTOUPDATE, $AUTOHEADER,
   $PERL, $MAKE, $EGREP, and $FGREP, instead of the corresponding
@@ -147,12 +151,11 @@ Do
   Use $sleep when you have to make sure that some file is newer
   than another.
 
-  Use `cat' or `grep' to display (part of) files that may be
-  interesting for debugging, so that when a user send a verbose
-  output we don't have to ask him for more details.  Display stderr
-  output on the stderr file descriptor.  If some redirected command
-  is likely to fail, and `set -e' is in effect, display its output
-  even in the failure case, before exiting.
+  Use `cat' or `grep' to display (part of) files that may be interesting
+  for debugging, so that when a user send a verbose output we don't have
+  to ask him for more details.  Display stderr output on the stderr file
+  descriptor.  If some redirected command is likely to fail, display its
+  output even in the failure case, before exiting.
 
   Use `Exit' rather than `exit' to abort a test.

diff --git a/tests/defs b/tests/defs
index f04a756..b5373a9 100644
--- a/tests/defs
+++ b/tests/defs
@@ -460,7 +460,7 @@ done
 ##  Ready to go...  ##
 ## ---------------- ##
 
-# Turn on shell traces.
 set -x
+set -e
 
 pwd

Attachment: set-e.pl
Description: Perl program

Attachment: 0001-tests-enable-errexit-shell-flag-by-default.patch.xz
Description: application/xz

Reply via email to