init.sh: don't use $ME_ or skip_ before they are defined
authorJim Meyering <meyering@redhat.com>
Fri, 11 Jun 2010 11:41:31 +0000 (13:41 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 11 Jun 2010 11:41:31 +0000 (13:41 +0200)
* tests/init.sh: Hoist definitions of $ME_ and skip_ to precede
their first uses.  Also hoist their companions: warn_, fail_,
framework_failure_, $stderr_fileno.  Prompted by a patch from
Stefano Lattarini.

ChangeLog
tests/init.sh

index 726e66a..5f93588 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-06-11  Jim Meyering  <meyering@redhat.com>
 
 2010-06-11  Jim Meyering  <meyering@redhat.com>
 
+       init.sh: don't use $ME_ or skip_ before they are defined
+       * tests/init.sh: Hoist definitions of $ME_ and skip_ to precede
+       their first uses.  Also hoist their companions: warn_, fail_,
+       framework_failure_, $stderr_fileno.  Prompted by a patch from
+       Stefano Lattarini.
+
        test-sys_socket: avoid set-but-not-used warnings from gcc
        * tests/test-sys_socket.c (main): Use "i" and "x", in order to
        avoid warning about set-but-not-used variables.
        test-sys_socket: avoid set-but-not-used warnings from gcc
        * tests/test-sys_socket.c (main): Use "i" and "x", in order to
        avoid warning about set-but-not-used variables.
index ef0957c..286bbf1 100644 (file)
 #   4. Finally
 #   $ exit
 
 #   4. Finally
 #   $ exit
 
+ME_=`expr "./$0" : '.*/\(.*\)$'`
+
+# We use a trap below for cleanup.  This requires us to go through
+# hoops to get the right exit status transported through the handler.
+# 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; }
+
+# Print warnings (e.g., about skipped and failed tests) to this file number.
+# Override by defining to say, 9, in init.cfg, and putting say,
+# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition
+# of TESTS_ENVIRONMENT in your tests/Makefile.am file.
+# 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 1; }
+
 # We require $(...) support unconditionally.
 # We require a few additional shell features only when $EXEEXT is nonempty,
 # in order to support automatic $EXEEXT emulation:
 # We require $(...) support unconditionally.
 # We require a few additional shell features only when $EXEEXT is nonempty,
 # in order to support automatic $EXEEXT emulation:
@@ -118,26 +140,6 @@ test -n "$EXEEXT" && shopt -s expand_aliases
 : ${MALLOC_PERTURB_=87}
 export MALLOC_PERTURB_
 
 : ${MALLOC_PERTURB_=87}
 export MALLOC_PERTURB_
 
-# We use a trap below for cleanup.  This requires us to go through
-# hoops to get the right exit status transported through the handler.
-# 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; }
-
-# Print warnings (e.g., about skipped and failed tests) to this file number.
-# Override by defining to say, 9, in init.cfg, and putting say,
-# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition
-# of TESTS_ENVIRONMENT in your tests/Makefile.am file.
-# 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 1; }
-
 # This is a stub function that is run upon trap (upon regular exit and
 # interrupt).  Override it with a per-test function, e.g., to unmount
 # a partition, or to undo any other global state changes.
 # This is a stub function that is run upon trap (upon regular exit and
 # interrupt).  Override it with a per-test function, e.g., to unmount
 # a partition, or to undo any other global state changes.
@@ -247,7 +249,6 @@ setup_()
   test "$VERBOSE" = yes && set -x
 
   initial_cwd_=$PWD
   test "$VERBOSE" = yes && set -x
 
   initial_cwd_=$PWD
-  ME_=`expr "./$0" : '.*/\(.*\)$'`
 
   pfx_=`testdir_prefix_`
   test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
 
   pfx_=`testdir_prefix_`
   test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \