[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: exits in the test suite
From: |
Akim Demaille |
Subject: |
FYI: exits in the test suite |
Date: |
27 Oct 2000 16:14:54 +0200 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) |
* tests/README: New file.
* tests/semantics.at: Don't just `exit 1' or `exit 77' from
configure.in: call AC_MSG_ERROR.
* tests/base.m4: Likewise.
* tests/m4sh.at: Likewise.
* tests/semantics.at (AT_CHECK_PROGS_PREPARE): New macro, eved
out of...
(AC_CHECK_PROG & AC_PATH_PROG): here.
Split into two individual tests...
(AC_CHECK_PROG & AC_CHECK_PROGS, AC_PATH_PROG & AC_PATH_PROGS): these.
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/autoconf/tests/Makefile.am,v
retrieving revision 1.35
diff -u -u -r1.35 Makefile.am
--- tests/Makefile.am 2000/10/26 09:52:34 1.35
+++ tests/Makefile.am 2000/10/27 13:58:16
@@ -26,7 +26,8 @@
# We don't actually distribute the testsuite, since one only
# needs m4 to build it, m4 being required anyway to install Autoconf.
-EXTRA_DIST = atgeneral.m4 atspecific.m4 aclocal.m4 \
+EXTRA_DIST = README \
+ atgeneral.m4 atspecific.m4 aclocal.m4 \
$(SUITE) mktests.sh
check-local: atconfig testsuite
Index: tests/README
===================================================================
RCS file: README
diff -N README
--- /dev/null Tue Aug 29 07:25:14 2000
+++ tests/README Fri Oct 27 06:58:16 2000
@@ -0,0 +1,20 @@
+ -*- outline -*-
+
+This directory holds the M4sugar, M4sh and Autoconf test suites.
+
+Here are a few rules on how to write tests.
+
+* Autoconf
+
+** Use of `exit'
+Don't directly `exit 1' or `exit 77', rather use `AC_MSG_ERROR'.
+First of all because when we have to read the test suite logs we are
+happy to know why `configure' exited thanks to the error
+message. Secondly, because `configure' traps the `exit' and pretty
+many shells fail to set $? to 77 when trapping `exit 77'. This
+results in the test suite not being able to check the exit status.
+
+** AC_MSG_ERROR
+Of course, since macro names are forbidden in `configure', if you
+really want to mention the macro name, you'll have to do without
+including `A?_' in the output.
Index: tests/base.at
===================================================================
RCS file: /cvs/autoconf/tests/base.at,v
retrieving revision 1.1
diff -u -u -r1.1 base.at
--- tests/base.at 2000/10/26 09:52:35 1.1
+++ tests/base.at 2000/10/27 13:58:16
@@ -38,7 +38,8 @@
AC_PLAIN_SCRIPT
TEST1
-test -z "$test1" && exit 1
+test -z "$test1" &&
+ AC_MSG_ERROR([\$test1 is empty])
exit 0
]])
Index: tests/m4sh.at
===================================================================
RCS file: /cvs/autoconf/tests/m4sh.at,v
retrieving revision 1.1
diff -u -u -r1.1 m4sh.at
--- tests/m4sh.at 2000/10/26 09:52:35 1.1
+++ tests/m4sh.at 2000/10/27 13:58:16
@@ -21,10 +21,12 @@
set -e
# Absolute
AS_MKDIR_P($pwd/1/2/3/4/5/6)
-test -d $pwd/1/2/3/4/5/6 || exit 1
+test -d $pwd/1/2/3/4/5/6 ||
+ AC_MSG_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
# Relative
AS_MKDIR_P(a/b/c/d/e/f)
-test -d a/b/c/d/e/f || exit 1
+test -d a/b/c/d/e/f ||
+ AC_MSG_ERROR([a/b/c/d/e/f has not been properly created])
exit 0
]])
Index: tests/semantics.at
===================================================================
RCS file: /cvs/autoconf/tests/semantics.at,v
retrieving revision 1.1
diff -u -u -r1.1 semantics.at
--- tests/semantics.at 2000/10/26 09:52:35 1.1
+++ tests/semantics.at 2000/10/27 13:58:16
@@ -10,9 +10,10 @@
# AC_TRY_LINK_FUNC
# ----------------
AT_CHECK_MACRO(AC_TRY_LINK_FUNC,
-[AC_TRY_LINK_FUNC(exit,, exit 1)
+[AC_TRY_LINK_FUNC(exit,,
+ [AC_MSG_ERROR([cannot find `exit'])])
AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
- exit 1)])
+ [AC_MSG_ERROR([found a nonexistent function])])])
@@ -29,7 +30,8 @@
# this test fail, so exit successfully if `cos' is in libc.
AT_CHECK_MACRO(AC_CHECK_LIB,
[AC_TRY_LINK_FUNC(cos, exit 0)
-AC_CHECK_LIB(m, cos,, exit 1)])
+AC_CHECK_LIB(m, cos,,
+ [AC_MSG_ERROR([cannot find `cos'])])])
# AC_CHECK_DECLS
@@ -195,13 +197,14 @@
## AC_CHECK_PROG & AC_PATH_PROG. ##
## ------------------------------ ##
-AT_SETUP(AC_CHECK_PROG & AC_PATH_PROG)
+# AT_CHECK_PROGS_PREPARE
+# ----------------------
# Create a sub directory `path' with 6 subdirs which all 7 contain
# an executable `tool'. `6' contains a `better' tool.
+AT_DEFINE([AT_CHECK_PROGS_PREPARE],
+[mkdir path
-mkdir path
-
cat >path/tool <<\EOF
#! /bin/sh
exit 0
@@ -213,74 +216,88 @@
mkdir path/$i
cp path/tool path/$i
done
-cp path/tool path/6/better
+cp path/tool path/6/better])
# -------------------------------- #
# AC_CHECK_PROG & AC_CHECK_PROGS. #
# -------------------------------- #
+AT_SETUP(AC_CHECK_PROG & AC_CHECK_PROGS)
+
+AT_CHECK_PROGS_PREPARE
+
AT_DATA(configure.in,
[[AC_INIT
pwd=`pwd`
path=`echo "1:2:3:4:5:6" | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
-fail=0
+fail=false
AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
-test "$TOOL1" = found || fail=1
+test "$TOOL1" = found || fail=:
# Yes, the semantics of this macro is weird.
AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
-test "$TOOL2" = not-found || fail=1
+test "$TOOL2" = not-found || fail=:
AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
-test "$TOOL3" = $pwd/path/2/tool || fail=1
+test "$TOOL3" = $pwd/path/2/tool || fail=:
AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
-test "$TOOL4" = better || fail=1
+test "$TOOL4" = better || fail=:
# When a tool is not found, and no value is given for not-found,
# the variable is left empty.
AC_CHECK_PROGS(TOOL5, missing,, $path)
-test -z "$TOOL5" || fail=1
+test -z "$TOOL5" || fail=:
AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
-test "$TOOL6" = tool || fail=1
+test "$TOOL6" = tool || fail=:
# no AC_OUTPUT, we don't need config.status.
-exit $fail
+$fail &&
+ AC_MSG_ERROR([[CHECK_PROG failed]])
+exit 0
]])
AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
AT_CHECK([./configure], 0, ignore)
+AT_CLEANUP(path config.log config.cache configure)
+
# ------------------------------ #
# AC_PATH_PROG & AC_PATH_PROGS. #
# ------------------------------ #
+AT_SETUP(AC_PATH_PROG & AC_PATH_PROGS)
+
+AT_CHECK_PROGS_PREPARE
+
AT_DATA(configure.in,
[[AC_INIT
pwd=`pwd`
path=`echo "1:2:3:4:5:6" | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
-fail=0
+fail=false
AC_PATH_PROG(TOOL1, tool, not-found, $path)
-test "$TOOL1" = $pwd/path/1/tool || fail=1
+test "$TOOL1" = $pwd/path/1/tool || fail=:
AC_PATH_PROG(TOOL2, better, not-found, $path)
-test "$TOOL2" = $pwd/path/6/better || fail=1
+test "$TOOL2" = $pwd/path/6/better || fail=:
# When a tool is not found, and no value is given for not-found,
# the variable is left empty.
AC_PATH_PROGS(TOOL3, missing,, $path)
-test -z "$TOOL3" || fail=1
+test -z "$TOOL3" || fail=:
AC_PATH_PROGS(TOOL4, missing tool better,, $path)
-test "$TOOL4" = $pwd/path/1/tool || fail=1
+test "$TOOL4" = $pwd/path/1/tool || fail=:
# no AC_OUTPUT, we don't need config.status.
-exit $fail
+$fail &&
+ AC_MSG_ERROR([[PATH_PROG failed]])
+exit 0
]])
AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
@@ -305,7 +322,8 @@
AC_C_INLINE
AC_C_VOLATILE
case "$GCC,$ac_cv_c_const,$ac_cv_c_inline,$ac_cv_c_volatile" in
- yes,*no*) exit 1;;
+ yes,*no*)
+ AC_MSG_ERROR([failed to detect `const', `inline' or `volatile' support]);;
esac]])
@@ -329,7 +347,8 @@
_AT_CHECK_AC_MACRO(
[AC_PROG_CPP
# If the preprocessor is not strict, just ignore
-test "x$ac_c_preproc_warn_flag" = xyes && exit 77
+test "x$ac_c_preproc_warn_flag" = xyes &&
+ AC_MSG_ERROR([preprocessor has no warning option], 77)
CPP="./mycpp $CPP"
AC_CHECK_HEADERS(stdio.h autoconf_io.h)])
@@ -355,10 +374,12 @@
_AT_CHECK_AC_MACRO(
[# Ignore if /lib/cpp doesn't work
-/lib/cpp </dev/null >/dev/null 2>&1 || exit 77
+/lib/cpp </dev/null >/dev/null 2>&1 ||
+ AC_MSG_ERROR([preprocessor doesn't work], 77)
CPP=./mycpp
AC_PROG_CPP
-test "x$ac_c_preproc_warn_flag" != xyes && exit 1
+test "x$ac_c_preproc_warn_flag" != xyes &&
+ AC_MSG_ERROR([failed to detect preprocessor warning option])
AC_CHECK_HEADERS(stdio.h autoconf_io.h)])
AT_CHECK_DEFINES(
- FYI: exits in the test suite,
Akim Demaille <=
- Re: FYI: exits in the test suite, Pavel Roskin, 2000/10/27
- Re: FYI: exits in the test suite, Pavel Roskin, 2000/10/27
- Re: FYI: exits in the test suite, Akim Demaille, 2000/10/27
- Re: FYI: exits in the test suite, Pavel Roskin, 2000/10/27
- Re: FYI: exits in the test suite, Pavel Roskin, 2000/10/28
- Re: FYI: exits in the test suite, Akim Demaille, 2000/10/30