automake-patches
[Top][All Lists]
Advanced

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

[PATCH 21/32] test setup: merge definitions of function for simple tests


From: Stefano Lattarini
Subject: [PATCH 21/32] test setup: merge definitions of function for simple tests
Date: Thu, 26 Jul 2012 14:04:47 +0200

* t/ax/plain-functions.sh: Delete, moving the definitions of ...
($stderr_fileno_): ... this variable ...
(warn_, fail_, skip_, skip_all_, fatal_, framework_failure_): ... and
these functions ...
* t/ax/test-init.sh: ... in here.  This allow us to use those functions
earlier in this file (instead of having to duplicate their behaviour
with inlined code).  The TAP-based tests are still able to override these
functions later to their TAP-enhanced equivalents when 'tap-functions.sh'
is sourced.
* Makefile.am (dist_noinst_DATA): Remove 't/ax/plain-functions.sh'.
* t/ax/tap-functions.sh: Adjust a comment.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 Makefile.am             |  1 -
 t/ax/plain-functions.sh | 40 -----------------------------------
 t/ax/test-init.sh       | 55 ++++++++++++++++++++++++++++++++++---------------
 3 files changed, 38 insertions(+), 58 deletions(-)
 delete mode 100644 t/ax/plain-functions.sh

diff --git a/Makefile.am b/Makefile.am
index 6aa94fa..495fc69 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -400,7 +400,6 @@ nodist_noinst_SCRIPTS = \
   t/wrap/automake-$(APIVERSION)
 dist_noinst_DATA = \
   t/ax/test-init.sh \
-  t/ax/plain-functions.sh \
   t/ax/tap-functions.sh
 
 # Few more static dependencies.
diff --git a/t/ax/plain-functions.sh b/t/ax/plain-functions.sh
deleted file mode 100644
index 6c5fef8..0000000
--- a/t/ax/plain-functions.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- shell-script -*-
-#
-# Copyright (C) 2011-2012 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
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Helper functions used by "plain" tests of the Automake testsuite
-# (i.e., tests that don't use any test protocol).
-
-# Print warnings (e.g., about skipped and failed tests) to this file
-# number.  Override by putting, say:
-#   AM_TESTS_ENVIRONMENT = stderr_fileno_=9; export stderr_fileno_;
-#   AM_TESTS_FD_REDIRECT = 9>&2
-# in your Makefile.am.
-# 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}
-
-# Copied from Gnulib's 'tests/init.sh'.
-warn_ () { echo "$@" 1>&$stderr_fileno_; }
-fail_ () { warn_ "$me: failed test: $@"; exit 1; }
-skip_ () { warn_ "$me: skipped test: $@"; exit 77; }
-fatal_ () { warn_ "$me: hard error: $@"; exit 99; }
-framework_failure_ () { warn_ "$me: set-up failure: $@"; exit 99; }
-
-# For compatibility with TAP functions.
-skip_all_ () { skip_ "$@"; }
-
-:
diff --git a/t/ax/test-init.sh b/t/ax/test-init.sh
index d4232d5..7817fe9 100644
--- a/t/ax/test-init.sh
+++ b/t/ax/test-init.sh
@@ -41,6 +41,43 @@ esc=''
 # is defined initially, so that saving and restoring $IFS works.
 IFS=$sp$tab$nl
 
+## ------------------------------------ ##
+##  General testsuite shell functions.  ##
+## ------------------------------------ ##
+
+# Print warnings (e.g., about skipped and failed tests) to this file
+# number.  Override by putting, say:
+#   AM_TESTS_ENVIRONMENT = stderr_fileno_=9; export stderr_fileno_;
+#   AM_TESTS_FD_REDIRECT = 9>&2
+# in your Makefile.am.
+# 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}
+
+# Helper functions used by "plain" tests of the Automake testsuite
+# (i.e., tests that don't use any test protocol).
+# TAP tests will override these functions with their TAP-enhanced
+# equivalents later  (see sourcing of 'tap-functions.sh' below).
+# These are copied from Gnulib's 'tests/init.sh'.
+warn_ () { echo "$@" 1>&$stderr_fileno_; }
+fail_ () { warn_ "$me: failed test: $@"; exit 1; }
+skip_ () { warn_ "$me: skipped test: $@"; exit 77; }
+fatal_ () { warn_ "$me: hard error: $@"; exit 99; }
+framework_failure_ () { warn_ "$me: set-up failure: $@"; exit 99; }
+# For compatibility with TAP functions.
+skip_all_ () { skip_ "$@"; }
+
+if test $am_using_tap = yes; then
+  am_tap_funcs_file=$am_testauxdir/tap-functions.sh
+  if test -f "$am_tap_funcs_file"; then
+    . "$am_tap_funcs_file" \
+      || fatal_ "error sourcing $am_tap_funcs_file"
+  else
+    fatal_ " $am_tap_funcs_file not found" >&2
+  fi
+  unset am_tap_funcs_file
+fi
+
 
 ## ---------------------- ##
 ##  Environment cleanup.  ##
@@ -100,6 +137,7 @@ unset pfx
 # Re-enable, it had been temporarily disabled above.
 set -e
 
+
 ## ---------------------------- ##
 ##  Auxiliary shell functions.  ##
 ## ---------------------------- ##
@@ -133,23 +171,6 @@ _am_exit ()
 }
 alias exit=_am_exit
 
-if test $am_using_tap = yes; then
-  am_funcs_file=tap-functions.sh
-else
-  am_funcs_file=plain-functions.sh
-fi
-
-if test -f "$am_testauxdir/$am_funcs_file"; then
-  . "$am_testauxdir/$am_funcs_file" || {
-    echo "$me: error sourcing $am_testauxdir/$am_funcs_file" >&2
-    exit 99
-  }
-else
-  echo "$me: $am_testauxdir/$am_funcs_file not found" >&2
-  exit 99
-fi
-unset am_funcs_file
-
 # cross_compiling
 # ---------------
 # Tell whether we are cross-compiling.  This is especially useful to skip
-- 
1.7.12.rc0




reply via email to

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