automake-patches
[Top][All Lists]
Advanced

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

[PATCH] {maint} tests: new subroutines for test skipping/failing


From: Stefano Lattarini
Subject: [PATCH] {maint} tests: new subroutines for test skipping/failing
Date: Sun, 16 Jan 2011 15:56:07 +0100
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

Hello automakers.

This patch stemmed from this discussion:
 <http://lists.gnu.org/archive/html/automake-patches/2011-01/msg00144.html>

I'd like to have the patch applied to maint, to make eventual integration
of new tests easier.  But the follow-up patches converting the testsuite
to the use of skip_() and providing more informative messages for skipped
tests should go to master only, to avoid unecessary "merging churn".

OK?

Regards,
  Stefano

-*-*-

tests: new subroutines for test skipping/failing.

* tests/defs.in (Exit): Move definition of this function earlier.
(warn_, skip_, fail_, framework_failure_): New functions, inspired
to the homonyms in gnulib's tests/init.sh.
($stderr_fileno_): New global variable, used by the new functions
above.
* tests/README: Updated.

From a suggestion by Ralf Wildenhues.
---
 ChangeLog     |   11 +++++++++++
 tests/README  |    4 ++++
 tests/defs.in |   39 ++++++++++++++++++++++++++-------------
 3 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 675f185..e1e03af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-16  Stefano Lattarini  <address@hidden>
+
+       tests: new subroutines for test skipping/failing.
+       * tests/defs.in (Exit): Move definition of this function earlier.
+       (warn_, skip_, fail_, framework_failure_): New functions, inspired
+       to the homonyms in gnulib's tests/init.sh.
+       ($stderr_fileno_): New global variable, used by the new functions
+       above.
+       * tests/README: Updated.
+       From a suggestion by Ralf Wildenhues.
+
 2011-01-16  Ralf Wildenhues  <address@hidden>
 
        Fix parallel-tests.test failure with HP-UX make.
diff --git a/tests/README b/tests/README
index 93f9cbf..c51b11a 100644
--- a/tests/README
+++ b/tests/README
@@ -100,6 +100,10 @@ Do
   Include ./defs in every test script (see existing tests for examples
   of how to do this).
 
+  Use the `skip_' function to skip tests, with a meaningful message if
+  possible.  Where convenient, use the `warn_' function to print generic
+  warnings, and the `fail_' function for test failures.
+
   For tests that use the `parallel-tests' Automake option, set the shell
   variable `parallel_tests' to "yes" before including ./defs.  Also,
   use for them a name that ends in `-p.test' and does not clash with any
diff --git a/tests/defs.in b/tests/defs.in
index ee19dbe..c5608e7 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -2,7 +2,7 @@
 # @configure_input@
 #
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -88,6 +88,31 @@ echo "$PATH"
 # (See note about `export' in the Autoconf manual.)
 export PATH
 
+# Print warnings (e.g., about skipped and failed tests) to this file number.
+# Override by putting, say:
+#   stderr_fileno_=9; export stderr_fileno_; exec 9>&2; $(SHELL)
+# in the definition of TESTS_ENVIRONMENT.
+# This is useful when using automake's parallel tests mode, to print
+# the reason for skip/failure to console, rather than to the .log files.
+: ${stderr_fileno_=2}
+
+warn_() { echo "$@" 1>&$stderr_fileno_; }
+fail_() { warn_ "$me: failed test: $@"; Exit 1; }
+skip_() { warn_ "$me: skipped test: $@"; Exit 77; }
+framework_failure_() { warn_ "$me: set-up failure: $@"; Exit 99; }
+
+# 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.
+# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
+# sh inside this function.
+Exit ()
+{
+  set +e
+  (exit $1)
+  exit $1
+}
+
 for tool in : $required
 do
   # Check that each required tool is present.
@@ -236,18 +261,6 @@ case "$srcdir" in
     ;;
 esac
 
-# 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.
-# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
-# sh inside this function.
-Exit ()
-{
-  set +e
-  (exit $1)
-  exit $1
-}
-
 curdir=`pwd`
 testSubDir=$me.dir
 test ! -d $testSubDir || {
-- 
1.7.2.3




reply via email to

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