]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
testsuite: use 'fatal_' and 'framework_failure_' for hard errors
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 7 Jun 2011 14:36:40 +0000 (16:36 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 11 Jun 2011 10:25:11 +0000 (12:25 +0200)
* tests/defs (require_xsi): Use `fatal_', not `framework_failure',
to report an invalid usage.
* tests/remake-gnulib-remove-header.test: Prefer using `fatal_'
with a proper error message over a direct call to `Exit 99'.
* tests/pr8365-remake-timing.test: Likewise.
* tests/cygnus-imply-foreign.test: Likewise.
* tests/missing6.test: Likewise.
* tests/cond8.test: Likewise.
* tests/cond33.test: Likewise.
* tests/python-virtualenv.test: Prefer using `framework_failure_'
with a proper error message over a direct call to `Exit 99'.
* tests/instspc-tests.sh: Prefer using `framework_failure_' and
`fatal_' over direct calls to `Exit 99'.
(fatal_): Define this (which is a simplified version of the one
in `tests/defs') for early uses (i.e., before `tests/defs'
gets sourced).
* tests/depmode-tests.sh: Likewise.  Also, simplify the
'get_depmodes' function and calls to it accordingly.

ChangeLog
tests/cond33.test
tests/cond8.test
tests/cygnus-imply-foreign.test
tests/defs
tests/depmod-tests.sh
tests/instspc-tests.sh
tests/missing6.test
tests/pr8365-remake-timing.test
tests/python-virtualenv.test
tests/remake-gnulib-remove-header.test

index 40c0d65970074a193dbdfbaacc09293c9a15000c..a7f9a4aa00a02cafae07d79c9cd86e564dd82f96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2011-06-08  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       testsuite: use 'fatal_' and 'framework_failure_' for hard errors
+       * tests/defs (require_xsi): Use `fatal_', not `framework_failure',
+       to report an invalid usage.
+       * tests/remake-gnulib-remove-header.test: Prefer using `fatal_'
+       with a proper error message over a direct call to `Exit 99'.
+       * tests/pr8365-remake-timing.test: Likewise.
+       * tests/cygnus-imply-foreign.test: Likewise.
+       * tests/missing6.test: Likewise.
+       * tests/cond8.test: Likewise.
+       * tests/cond33.test: Likewise.
+       * tests/python-virtualenv.test: Prefer using `framework_failure_'
+       with a proper error message over a direct call to `Exit 99'.
+       * tests/instspc-tests.sh: Prefer using `framework_failure_' and
+       `fatal_' over direct calls to `Exit 99'.
+       (fatal_): Define this (which is a simplified version of the one
+       in `tests/defs') for early uses (i.e., before `tests/defs'
+       gets sourced).
+       * tests/depmode-tests.sh: Likewise.  Also, simplify the
+       'get_depmodes' function and calls to it accordingly.
+
 2011-06-08  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        self tests: check new 'fatal_' function
index 126a4c1982acb5c29bdb835dc5c72e5ece9e8f0c..149795d4985204ac37f32f04da1a2c86da6df82f 100755 (executable)
@@ -47,7 +47,7 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 
-cwd=`pwd` || Exit 99
+cwd=`pwd` || fatal_ "cannot get current directory"
 mkdir nowhere
 chmod a-w nowhere
 
index 3fe7b5c9e913ea8f89310b636bfcdb4c025f6426..07bf2d0d22864de7796c173324788bf249f454c1 100755 (executable)
@@ -59,7 +59,7 @@ END
 
 cp x.c y.c
 
-instdir=`pwd`/_inst || Exit 99
+instdir=`pwd`/_inst || fatal_ "cannot get current directory"
 
 # Skip the rest of the test in case of e.g. missing C compiler.
 ./configure --prefix="$instdir" x=yes || Exit $?
index 9a20f21e0523547e967229e6c8b787007a96adf2..1a8d7d3ba738c4af39b967e2eaab95f87ddda954 100755 (executable)
@@ -51,7 +51,8 @@ mv -f Makefile.sav Makefile.am
 # Try again, this time enabling cygnus mode from configure.in.
 cp configure.in configure.sav
 sed 's/^AM_INIT_AUTOMAKE$/&([gnits cygnus])/' configure.sav >configure.in
-cmp configure.in configure.sav && Exit 99 # sanity check
+cmp configure.in configure.sav && fatal_ 'failed to edit configure.in'
+
 $ACLOCAL --force
 $AUTOMAKE -Werror
 mv -f configure.sav configure.in
index b65989a9bd2cd3d03196439b6994ddb43c874aff..df62751ef4b8ff63d2fb2386fb47fa426de7f2d0 100644 (file)
@@ -306,7 +306,7 @@ get_shell_script ()
 # Skip the test if the given shell fails to support common XSI constructs.
 require_xsi ()
 {
-  test $# -eq 1 || framework_failure_ "require_xsi needs exactly one arg"
+  test $# -eq 1 || fatal_ "require_xsi needs exactly one argument"
   echo "$me: trying some XSI constructs with $1"
   $1 -c "$xsi_shell_code" || skip_ "$1 lacks XSI features"
 }
index 36b57190f893aee15f949f5ab479813db9070f1c..a21f6182f04d576bfcec25cf1ae1b4e3748e06b1 100755 (executable)
@@ -62,10 +62,14 @@ fi
 
 set -e
 
+# We need this early.  It will be overridden when we source ./defs below,
+# which will offer a more proper implementation.
+fatal_ () { echo "$0: $*" >&2; exit 99; }
+
 case $# in
-  0) echo "$0: missing argument" >&2; exit 99;;
+  0) fatal_ "missing argument";;
   1) ;;
-  *) echo "$0: too many arguments" >&2; exit 99;;
+  *) fatal_ "too many arguments";;
 esac
 
 case $1 in
@@ -77,8 +81,7 @@ case $1 in
     depmode=`expr /"$1" : '.*/depcomp-\(.*\)\.depmod'`
     ;;
   *)
-    echo "$0: invalid argument '$1'" >&2
-    exit 99
+    fatal_ "invalid argument '$1'"
     ;;
 esac
 
@@ -136,7 +139,7 @@ END
   : > success
 }
 
-# Usage: get_depmodes DEPCOMP-FILE PROGRAM-NAME
+# Usage: get_depmodes DEPCOMP-FILE
 get_depmodes ()
 {
   # Keep this in sync with the contents of depend.m4.
@@ -144,10 +147,8 @@ get_depmodes ()
                   | grep -v '^none$'` \
     && : Turn newlines and tabs into spaces, and strip extra whitespace. \
     && all_depmodes=`echo $all_depmodes` \
-    && test -n "$all_depmodes" || {
-      echo "$2: failed to extract list of valid depmodes from '$1'" >&2
-      exit 99
-    }
+    && test -n "$all_depmodes" \
+    || fatal_ "can't extract list of valid depmodes from '$1'"
 }
 
 if test x"$action" = x"generate-makefile"; then
@@ -182,8 +183,9 @@ set -e
 # the files we need.  So remove the other files created by ./defs.  And
 # check we really are in a temporary `*.dir' directory in the build tree,
 # since the last thing we want is to remove some random user files!
-test -f ../defs-static && test -f ../defs || Exit 99
-case `pwd` in *.dir);; *) Exit 99;; esac
+test -f ../defs-static && test -f ../defs \
+  && case `pwd` in *.dir) :;; *) false;; esac \
+  || fatal_ "running from the wrong directory"
 rm -f *
 
 if test x"$action" = x"generate-data"; then
@@ -194,18 +196,17 @@ if test x"$action" = x"generate-data"; then
   Exit 0
 fi
 
-get_depmodes "$top_testsrcdir/lib/depcomp" "$me"
+get_depmodes "$top_testsrcdir/lib/depcomp"
 case " $all_depmodes " in
   *" $depmode "*) ;;
-  *) echo "$me: invalid depmode '$depmode'" >&2; exit 99;;
+  *) fatal_ "invalid depmode '$depmode'";;
 esac
 
 ###  If we are still here, we have to run a test ...
 
-test -f ../depmod-data.dir/success || {
-  echo "$me: setup by depmod-data.test failed" >&2
-  Exit 99
-}
+if test ! -f ../depmod-data.dir/success; then
+  framework_failure_ "depmod-data.test failure"
+fi
 
 ../depmod-data.dir/configure am_cv_CC_dependencies_compiler_type=$depmode
 
index c57efb79240a4b11c4bc29260aa7e8063fa07dae..9c6c968633baebf6af93d1f169bb58f5244d0dfd 100755 (executable)
@@ -44,11 +44,15 @@ else
 fi
 
 set -e
+# We need this early.  It will be overridden when we source ./defs below,
+# which will offer a more proper implementation.
+fatal_ () { echo "$0: $*" >&2; exit 99; }
 
 case $# in
-  0) echo "$0: missing argument" >&2; exit 99;;
+  0) fatal_ "missing argument";;
   1) ;;
-  *) echo "$0: too many arguments" >&2; exit 99;;
+  *) fatal_ "too many arguments";;
 esac
 
 case $1 in
@@ -64,8 +68,7 @@ case $1 in
     instspc_test_name=`expr /"$1" : '.*/install-\(.*\)\.instspc'`
     ;;
   *)
-    echo "$0: invalid argument '$1'" >&2
-    exit 99
+    fatal_ "invalid argument '$1'"
     ;;
 esac
 
@@ -75,7 +78,8 @@ define_problematic_string ()
 {
   tst=$1
   shift
-  eval "instspc__$tst=\$1" || exit 99
+  eval "instspc__$tst=\$1" \
+    || fatal_ "define_problematic_string: bad argument: '$tst'"
   shift
   instspc_names_list="$instspc_names_list $tst"
   # Some of the "problematic" characters cannot be used in the name of
@@ -284,8 +288,9 @@ set -e
 # the files we need.  So remove the other files created by ./defs.  And
 # check we really are in a temporary `*.dir' directory in the build tree,
 # since the last thing we want is to remove some random user files!
-test -f ../defs-static && test -f ../defs || Exit 99
-case `pwd` in *.dir);; *) Exit 99;; esac
+test -f ../defs-static && test -f ../defs \
+  && case `pwd` in *.dir) :;; *) false;; esac \
+  || fatal_ "running from the wrong directory"
 rm -f *
 
 if test x"$instspc_action" = x"generate-data"; then
@@ -298,16 +303,13 @@ fi
 
 ###  If we are still here, we have to run a test ...
 
-eval "instspc_test_string=\${instspc__$instspc_test_name}" || Exit 99
-if test x"$instspc_test_string" = x; then
-  echo "$me: invalid test name: '$instspc_test_name'" >&2
-  Exit 99
-fi
+eval "instspc_test_string=\${instspc__$instspc_test_name}" \
+  && test x"$instspc_test_string" != x \
+  || fatal_ "invalid test name: '$instspc_test_name'"
 
-test -f ../instspc-data.dir/success || {
-  echo "$me: setup by instspc-data.test failed" >&2
-  Exit 99
-}
+if test ! -f ../instspc-data.dir/success; then
+  framework_failure_ "instspc-data.test failure"
+fi
 
 # Skip if this system doesn't support these characters in file names.
 mkdir "./$instspc_test_string" || Exit 77
@@ -323,8 +325,7 @@ case $instspc_action in
     relbuilddir=..
     ;;
   *)
-    echo "$me: internal error: invalid action '$instspc_action'"
-    Exit 99
+    fatal_ "invalid action '$instspc_action'"
     ;;
 esac
 
index 2e257f157d3b2246f0d1f78235d4ae8cef2033fa..b6f1562389206e91a07c16294a19723327ae2ed0 100755 (executable)
@@ -38,7 +38,7 @@ $AUTOMAKE
 $MAKE
 
 sed 's/^dnl!! //' < configure.ac > configure.tmp
-cmp configure.ac configure.tmp && Exit 99 # sanity check
+cmp configure.ac configure.tmp && fatal_ 'failed to edit configure.ac'
 mv -f configure.tmp configure.ac
 
 $MAKE 2>stderr || { cat stderr >&2; Exit 1; }
index 5dbebc6309dc54db03df4b1a6391b1758a858089..f549bf1465603abbc8077f7dc67558ea777ff413 100755 (executable)
@@ -42,7 +42,8 @@ $AUTOCONF
 
 ./configure
 $MAKE Makefile
-$EGREP 'FOOBAR|zardoz' Makefile && Exit 99 # Sanity check.
+# Sanity check.
+$EGREP 'FOOBAR|zardoz' Makefile && fatal_ 'unexpected AC_SUBST in Makefile'
 
 echo 'AC_SUBST([FOOBAR])' >> configure.in
 
index c36c2b770f8fbb9e22dd466cc6028148999786da..5ddd8fb7217e8c92a71a5931726833378a07b3ff 100755 (executable)
@@ -30,7 +30,9 @@ virtualenv --verbose virtenv && test -f virtenv/bin/activate \
 # Activate the virtualenv.
 . ./virtenv/bin/activate
 # Sanity check.
-test -n "$VIRTUAL_ENV" || Exit 99
+if test -z "$VIRTUAL_ENV"; then
+  framework_failure_ "can't activate python virtual environment"
+fi
 
 cwd=`pwd`
 py_version=`python -c 'import sys; print("%u.%u" % tuple(sys.version_info[:2]))'`
index de5a2fa1be8954927b317c7fb15bc45e9c0483d2..9e9b4e2d899299317b48aa2a23b1818962d02189 100755 (executable)
@@ -108,7 +108,7 @@ for vpath in : false; do
 
   $sleep
   sed -e 's/^\( *override_stdio\)=.*$/\1=false/' $srcdir/macros.m4 > t
-  diff $srcdir/macros.m4 t && Exit 99 # sanity check
+  diff $srcdir/macros.m4 t && fatal_ "failed to edit macros.m4"
   mv -f t $srcdir/macros.m4
 
   using_gmake || $MAKE Makefile
@@ -120,7 +120,7 @@ for vpath in : false; do
 
   $sleep
   sed -e 's/^\( *override_stdio\)=.*$/\1=:/' $srcdir/macros.m4 > t
-  diff $srcdir/macros.m4 t && Exit 99 # sanity check
+  diff $srcdir/macros.m4 t && fatal_ "failed to edit macros.m4"
   mv -f t $srcdir/macros.m4
 
   using_gmake || $MAKE Makefile