automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 03/14] Do not SKIP a test on a command failing with `77' exit sta


From: Stefano Lattarini
Subject: [PATCH 03/14] Do not SKIP a test on a command failing with `77' exit status.
Date: Fri, 2 Jul 2010 13:46:43 +0200
User-agent: KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.4; i686; ; )

This patch might seem a bit controversial, so let me elaborate on it.

Before this patch, if a command failed with status `77 in a
test script using the `errexit' (`-e') shell flag, the *global*
test outcome was considered a SKIP, bacause the a value of `77'
for `$?' was passed to the exit trap.  Indded, this happenend
in practice, as an autoconf-generated configure script exits
with status `77' if it fails to find e.g. a required compiler.
This patch modify the exit trap, so that only an *explicit*
`Exit 77' makes the test outcome be considered a SKIP.

I think that forcing ourselves to be explicit about test skips could 
help us to better find out hidden dependencies, and to avoid false 
negatives (in the form of unexpected skips).  So, even if I had 
originally considered this patch just as a temporary hack (used to
see which tests need a C compiler without explicitly requiring it),
I now strongly believe that it should be applied upstream.

Note that I kept a fairly complete description of the *motivations* 
for the patch in the git commit message (but not in the ChangeLog 
entry).  I feel this is necessary, as those motivations might not be 
obvious, and I prefer to have them clearly recorded in the project 
history, rather than being forced to re-discover or re-explain them in 
the future.

Regards,
    Stefano
From 9f17b0467a3e9565091015e32c103e55f2eb3b46 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Fri, 2 Jul 2010 12:41:29 +0200
Subject: [PATCH 03/14] Do not SKIP a test on a command failing with `77' exit 
status.

Before this change, if a command failed with status `77 in a
test script using the `errexit' (`-e') shell flag, the *global*
test outcome was considered a SKIP, bacause the a value of `77'
for `$?' was passed to the exit trap.  Indded, this happenend
in practice, as an autoconf-generated configure script exits
with status `77' if it fails to find e.g. a required compiler.
This patch modify the exit trap, so that only an *explicit*
`Exit 77' makes the test outcome be considered a SKIP.

I think that forcing ourselves to be explicit about test skips could
help us to better find out hidden dependencies, and to avoid false
negatives (in the form of unexpected skips).  So, even if I had
originally considered this patch just as a temporary hack (used to
see which tests need a C compiler without explicitly requiring it),
I now strongly believe that it should be applied upstream.

* tests/defs.in ($am_test_skipped): New variable, initialized
to "no".
(Exit): Set $am_test_skipped to "yes" if passed an exit status
of 77.
(trap '...' 0): Reset exit status to `1' if it is = `77', but
$am_test_skipped is not set to "yes".
* tests/upc.test: Skip it explicitly if ./configure exit with
status 77.
* tests/upc3.test: Likewise.
---
 ChangeLog       |   19 +++++++++++++++++++
 tests/defs.in   |    9 +++++++++
 tests/upc.test  |    4 +++-
 tests/upc3.test |    4 +++-
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3ea6ad0..3bde2a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2010-07-02  Stefano Lattarini  <address@hidden>
 
+       Do not SKIP a test on a command failing with `77' exit status.
+       Before this change, if a command failed with status `77 in a
+       test script using the `errexit' (`-e') shell flag, the *global*
+       test outcome was considered a SKIP, bacause the a value of `77'
+       for `$?' was passed to the exit trap.  Indded, this happenend
+       in practice, as an autoconf-generated configure script exits
+       with status `77' if it fails to find e.g. a required compiler.
+       This patch modify the exit trap, so that only an *explicit*
+       `Exit 77' makes the test outcome be considered a SKIP.
+       * tests/defs.in ($am_test_skipped): New variable, initialized
+       to "no".
+       (Exit): Set $am_test_skipped to "yes" if passed an exit status
+       of 77.
+       (trap '...' 0): Reset exit status to `1' if it is = `77', but
+       $am_test_skipped is not set to "yes".
+       * tests/upc.test: Skip it explicitly if ./configure exit with
+       status 77.
+       * tests/upc3.test: Likewise.
+
        Drop useless "cc" requirement from a test script.
        * tests/targetclash.test ($required): Do not require `cc', as
        it's never truly used.
diff --git a/tests/defs.in b/tests/defs.in
index 1d6af76..3fef7b1 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -254,6 +254,11 @@ case "$srcdir" in
     ;;
 esac
 
+# This is to ensure that a test script does not result as a SKIP
+# just because a command in it happens to exit with status 77 when
+# the `errexit' (aka `set -e') shell flag is active.
+am_test_skipped=no
+
 # We use a trap below for cleanup.  This requires us to go through
 # hoops to get the right exit status transported through the signal.
 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
@@ -262,6 +267,7 @@ esac
 Exit ()
 {
   set +e
+  test 77 = $1 && am_test_skipped=yes
   (exit $1)
   exit $1
 }
@@ -278,6 +284,9 @@ address@hidden@
 if test "$sh_errexit_works" = yes; then
   trap 'exit_status=$?
     set +e
+    if test $exit_status -eq 77 && test x"$am_test_skipped" != x"yes"; then
+      exit_status=1
+    fi
     cd "$curdir"
     case $exit_status,$keep_testdirs in
     0,)
diff --git a/tests/upc.test b/tests/upc.test
index 3c55ccb..725166c 100755
--- a/tests/upc.test
+++ b/tests/upc.test
@@ -45,5 +45,7 @@ $ACLOCAL
 $AUTOMAKE
 $AUTOCONF
 
-./configure
+# Skip the test if configure suggests so.
+./configure || Exit $?
+
 $MAKE distcheck
diff --git a/tests/upc3.test b/tests/upc3.test
index f575b9a..870c66e 100755
--- a/tests/upc3.test
+++ b/tests/upc3.test
@@ -60,5 +60,7 @@ $ACLOCAL
 $AUTOMAKE
 $AUTOCONF
 
-./configure
+# Skip the test if configure suggests so.
+./configure || Exit $?
+
 $MAKE distcheck
-- 
1.6.5


reply via email to

[Prev in Thread] Current Thread [Next in Thread]