Use AC_MSG_ERROR in the test suite, not just `exit'.

* 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.
This commit is contained in:
Akim Demaille 2000-10-27 14:15:28 +00:00
parent c46d9d8480
commit 7eadb5fda3
7 changed files with 91 additions and 31 deletions

View File

@ -1,3 +1,18 @@
2000-10-27 Akim Demaille <akim@epita.fr>
Use AC_MSG_ERROR in the test suite, not just `exit'.
* 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.
2000-10-27 Pavel Roskin <proski@gnu.org>
* autoconf.sh: Recognize short options followed by arguments

View File

@ -26,7 +26,8 @@ SUITE = suite.at \
# 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

View File

@ -71,7 +71,7 @@ SUITE = suite.at m4sugar.at m4sh.at base.at tools.at semantics.a
# 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 $(SUITE) mktests.sh
EXTRA_DIST = README atgeneral.m4 atspecific.m4 aclocal.m4 $(SUITE) mktests.sh
# The files which contains macro we check for syntax.
@ -83,7 +83,7 @@ CLEANFILES = debug-*.sh macro configure configure.in config.status
DISTCLEANFILES = atconfig testsuite
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES = atconfig
DIST_COMMON = Makefile.am Makefile.in atconfig.in
DIST_COMMON = README Makefile.am Makefile.in atconfig.in
PACKAGE = @PACKAGE@

20
tests/README Normal file
View File

@ -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.

View File

@ -38,7 +38,8 @@ test3=set])
AC_PLAIN_SCRIPT
TEST1
test -z "$test1" && exit 1
test -z "$test1" &&
AC_MSG_ERROR([\$test1 is empty])
exit 0
]])

View File

@ -21,10 +21,12 @@ pwd=`pwd`
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
]])

View File

@ -10,9 +10,10 @@ EOF
# 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 @@ AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
# 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,12 +197,13 @@ rm ac-exists1 ac-exists2],
## 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.
mkdir path
AT_DEFINE([AT_CHECK_PROGS_PREPARE],
[mkdir path
cat >path/tool <<\EOF
#! /bin/sh
@ -213,74 +216,88 @@ do
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_CONST
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 @@ chmod +x mycpp
_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 @@ chmod +x mycpp
_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(