]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Use AC_MSG_ERROR in the test suite, not just `exit'.
authorAkim Demaille <akim@epita.fr>
Fri, 27 Oct 2000 14:15:28 +0000 (14:15 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 27 Oct 2000 14:15:28 +0000 (14:15 +0000)
* 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.

ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/README [new file with mode: 0644]
tests/base.at
tests/m4sh.at
tests/semantics.at

index 822748d324174ece5f7c3872d095ca918c9a697a..8528657f2a86faf3aebcada0d1d7034dd340cbd1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 912bd6ada637b60cfba25a4e324011a143eceaa4..de8de2daa99bebdaaef76a4e95526332c20c5d52 100644 (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
index a6394b0d0c16102c6245810297cbd4439eae5072..4a35440f0fc3d3488e87ee5103d77578e374adcf 100644 (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@
diff --git a/tests/README b/tests/README
new file mode 100644 (file)
index 0000000..aff89a2
--- /dev/null
@@ -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 3406bd839210b7931c729f4da326dd337e4e7e65..bcd54a79ea3927d42c91d59f65319aec90199ee6 100644 (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
 ]])
 
index dea8af13dd0d61fc09c3ff75ddd8cb8d85c7a21d..88aa3ed323c053aee7c28b5cce5e6189423b228f 100644 (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
 ]])
 
index 1c5a7e9d1535bd482c7028f83552cf4f2043c331..3c538941ac6c3460843ed030582e98fb8f9c832c 100644 (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(