+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
$AUTOCONF
$AUTOMAKE
-cwd=`pwd` || Exit 99
+cwd=`pwd` || fatal_ "cannot get current directory"
mkdir nowhere
chmod a-w nowhere
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 $?
# 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
# 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"
}
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
depmode=`expr /"$1" : '.*/depcomp-\(.*\)\.depmod'`
;;
*)
- echo "$0: invalid argument '$1'" >&2
- exit 99
+ fatal_ "invalid argument '$1'"
;;
esac
: > 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.
| 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
# 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
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
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
instspc_test_name=`expr /"$1" : '.*/install-\(.*\)\.instspc'`
;;
*)
- echo "$0: invalid argument '$1'" >&2
- exit 99
+ fatal_ "invalid argument '$1'"
;;
esac
{
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
# 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
### 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
relbuilddir=..
;;
*)
- echo "$me: internal error: invalid action '$instspc_action'"
- Exit 99
+ fatal_ "invalid action '$instspc_action'"
;;
esac
$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; }
./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
# 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]))'`
$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
$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