On Thursday 23 July 2009 21:49:18 Eric Blake wrote:
> According to Romain Lenglet on 7/21/2009 7:20 AM:
> >> A big thanks for this - it is long overdue.  I don't have an erlang
> >> interpreter handy on my primary development machine; do you have a URL
> >> to a tarball so I can try building one and to this a bit more
> >> thoroughly?
> >
> > There are packages for most distributions.
> > There are source tarballs there:
> > http://www.erlang.org/download.html
> > Any version downloadable from there is OK. All are stable.
>
> I still haven't played with installing it, but thanks for the link.
>
> > I attached a new patch which takes into account your other comments
> > below.
>
> I've tweaked it a bit (I renamed the helper macro AT_SETUP_ERLANG, then
> simplified its use; added comments to visually separate test groups; and
> ensured that all the Erlang tests run with make check TESTSUITEFLAGS='-k
> Erlang), then applied.  I confirmed that all tests that require an Erlang
> interpreter are skipped on machines without one.  Please validate that the
> latest autoconf.git passes for you.

Thanks a lot, it works fine for me.

I have finished cleaning my patch to make the macros testable with 
AT_CHECK_MACRO / AT_CHECK_ENV. You were right, there were 2 problems:

1) The macros define variables without the ac_.* and AC_.* prefixes. I have 
renamed the erlang_cv_.* variables into ac_cv_erlang_.*, and added the 
ERLANG_.* variables in the list of exceptions in AT_CHECK_ENV.

2) Some files were left over by the compiler and the tests: conftest.beam and 
conftest.out. I now delete them properly.

This allows us to test all the macros using AT_CHECK_MACRO, which is much 
cleaner and concise.
Cf. the attached diff against the latest master branch.
Sorry for the delay for sending you that patch!

Thanks,
--
Romain Lenglet
diff --git a/ChangeLog b/ChangeLog
index dac5b0c..4d94ba0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-07-23  Romain Lenglet  <[email protected]>
 
+	Clean up temporary files generated by Erlang macros.
+	* lib/autoconf/erlang.m4: Delete conftest.out; renamed erlang_cv_*
+	cache variables into ac_cv_erlang_*.
+	* lib/autoconf/general.m4: Delete conftest.beam files generated by
+	Erlang compiler.
+	* tests/local.at: Ignore variables defined by Erlang macros, in
+	AT_CHECK_ENV.
+
 	Add autotests for Erlang macros.
 	* tests/erlang.at: Added tests for all macros in erlang.m4.
 	* tests/Makefile.am: Added erlang.at.
diff --git a/lib/autoconf/erlang.m4 b/lib/autoconf/erlang.m4
index 72268be..0c4504d 100644
--- a/lib/autoconf/erlang.m4
+++ b/lib/autoconf/erlang.m4
@@ -191,7 +191,7 @@ AC_DEFUN([AC_ERLANG_CHECK_LIB],
 [AC_REQUIRE([AC_ERLANG_PATH_ERLC])[]dnl
 AC_REQUIRE([AC_ERLANG_PATH_ERL])[]dnl
 AC_CACHE_CHECK([for Erlang/OTP '$1' library subdirectory],
-    [erlang_cv_lib_dir_$1],
+    [ac_cv_erlang_lib_dir_$1],
     [AC_LANG_PUSH(Erlang)[]dnl
      AC_RUN_IFELSE(
 	[AC_LANG_PROGRAM([], [dnl
@@ -204,23 +204,25 @@ AC_CACHE_CHECK([for Erlang/OTP '$1' library subdirectory],
 		0
 	    end,
 	    halt(ReturnValue)])],
-	[erlang_cv_lib_dir_$1=`cat conftest.out`],
+	[ac_cv_erlang_lib_dir_$1=`cat conftest.out`
+	 rm -f conftest.out],
 	[if test ! -f conftest.out; then
 	     AC_MSG_FAILURE([test Erlang program execution failed])
 	 else
-	     erlang_cv_lib_dir_$1="not found"
+	     ac_cv_erlang_lib_dir_$1="not found"
+	     rm -f conftest.out
 	 fi])
      AC_LANG_POP(Erlang)[]dnl
     ])
 AC_CACHE_CHECK([for Erlang/OTP '$1' library version],
-    [erlang_cv_lib_ver_$1],
-    [AS_IF([test "$erlang_cv_lib_dir_$1" = "not found"],
-	[erlang_cv_lib_ver_$1="not found"],
-	[erlang_cv_lib_ver_$1=`AS_ECHO(["$erlang_cv_lib_dir_$1"]) | sed -n -e 's,^.*-\([[^/-]]*\)$,\1,p'`])[]dnl
+    [ac_cv_erlang_lib_ver_$1],
+    [AS_IF([test "$ac_cv_erlang_lib_dir_$1" = "not found"],
+	[ac_cv_erlang_lib_ver_$1="not found"],
+	[ac_cv_erlang_lib_ver_$1=`AS_ECHO(["$ac_cv_erlang_lib_dir_$1"]) | sed -n -e 's,^.*-\([[^/-]]*\)$,\1,p'`])[]dnl
     ])
-AC_SUBST([ERLANG_LIB_DIR_$1], [$erlang_cv_lib_dir_$1])
-AC_SUBST([ERLANG_LIB_VER_$1], [$erlang_cv_lib_ver_$1])
-AS_IF([test "$erlang_cv_lib_dir_$1" = "not found"], [$3], [$2])
+AC_SUBST([ERLANG_LIB_DIR_$1], [$ac_cv_erlang_lib_dir_$1])
+AC_SUBST([ERLANG_LIB_VER_$1], [$ac_cv_erlang_lib_ver_$1])
+AS_IF([test "$ac_cv_erlang_lib_dir_$1" = "not found"], [$3], [$2])
 ])# AC_ERLANG_CHECK_LIB
 
 
@@ -231,7 +233,7 @@ AC_DEFUN([AC_ERLANG_SUBST_ROOT_DIR],
 [AC_REQUIRE([AC_ERLANG_NEED_ERLC])[]dnl
 AC_REQUIRE([AC_ERLANG_NEED_ERL])[]dnl
 AC_CACHE_CHECK([for Erlang/OTP root directory],
-    [erlang_cv_root_dir],
+    [ac_cv_erlang_root_dir],
     [AC_LANG_PUSH(Erlang)[]dnl
      AC_RUN_IFELSE(
 	[AC_LANG_PROGRAM([], [dnl
@@ -239,11 +241,13 @@ AC_CACHE_CHECK([for Erlang/OTP root directory],
 	    file:write_file("conftest.out", RootDir),
 	    ReturnValue = 0,
 	    halt(ReturnValue)])],
-	[erlang_cv_root_dir=`cat conftest.out`],
-	[AC_MSG_FAILURE([test Erlang program execution failed])])
+	[ac_cv_erlang_root_dir=`cat conftest.out`
+	 rm -f conftest.out],
+	[rm -f conftest.out
+	 AC_MSG_FAILURE([test Erlang program execution failed])])
      AC_LANG_POP(Erlang)[]dnl
     ])
-AC_SUBST([ERLANG_ROOT_DIR], [$erlang_cv_root_dir])
+AC_SUBST([ERLANG_ROOT_DIR], [$ac_cv_erlang_root_dir])
 ])# AC_ERLANG_SUBST_ROOT_DIR
 
 
@@ -253,7 +257,7 @@ AC_DEFUN([AC_ERLANG_SUBST_LIB_DIR],
 [AC_REQUIRE([AC_ERLANG_NEED_ERLC])[]dnl
 AC_REQUIRE([AC_ERLANG_NEED_ERL])[]dnl
 AC_CACHE_CHECK([for Erlang/OTP library base directory],
-    [erlang_cv_lib_dir],
+    [ac_cv_erlang_lib_dir],
     [AC_LANG_PUSH(Erlang)[]dnl
      AC_RUN_IFELSE(
 	[AC_LANG_PROGRAM([], [dnl
@@ -261,11 +265,13 @@ AC_CACHE_CHECK([for Erlang/OTP library base directory],
 	    file:write_file("conftest.out", LibDir),
 	    ReturnValue = 0,
 	    halt(ReturnValue)])],
-	[erlang_cv_lib_dir=`cat conftest.out`],
-	[AC_MSG_FAILURE([test Erlang program execution failed])])
+	[ac_cv_erlang_lib_dir=`cat conftest.out`
+	 rm -f conftest.out],
+	[rm -f conftest.out
+	 AC_MSG_FAILURE([test Erlang program execution failed])])
      AC_LANG_POP(Erlang)[]dnl
     ])
-AC_SUBST([ERLANG_LIB_DIR], [$erlang_cv_lib_dir])
+AC_SUBST([ERLANG_LIB_DIR], [$ac_cv_erlang_lib_dir])
 ])# AC_ERLANG_SUBST_LIB_DIR
 
 
@@ -311,7 +317,7 @@ AC_DEFUN([AC_ERLANG_SUBST_ERTS_VER],
 [AC_REQUIRE([AC_ERLANG_NEED_ERLC])[]dnl
 AC_REQUIRE([AC_ERLANG_NEED_ERL])[]dnl
 AC_CACHE_CHECK([for Erlang/OTP ERTS version],
-    [erlang_cv_erts_ver],
+    [ac_cv_erlang_erts_ver],
     [AC_LANG_PUSH([Erlang])[]dnl
      AC_RUN_IFELSE(
 	[AC_LANG_PROGRAM([], [dnl
@@ -319,9 +325,11 @@ AC_CACHE_CHECK([for Erlang/OTP ERTS version],
 	    file:write_file("conftest.out", Version),
 	    ReturnValue = 0,
 	    halt(ReturnValue)])],
-	[erlang_cv_erts_ver=`cat conftest.out`],
-	[AC_MSG_FAILURE([test Erlang program execution failed])])
+	[ac_cv_erlang_erts_ver=`cat conftest.out`
+	 rm -f conftest.out],
+	[rm -f conftest.out
+	 AC_MSG_FAILURE([test Erlang program execution failed])])
      AC_LANG_POP([Erlang])[]dnl
     ])
-AC_SUBST([ERLANG_ERTS_VER], [$erlang_cv_erts_ver])
+AC_SUBST([ERLANG_ERTS_VER], [$ac_cv_erlang_erts_ver])
 ])# AC_ERLANG_SUBST_ERTS_VER
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 9eaae80..ac67c4a 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2722,7 +2722,8 @@ AC_DEFUN([_AC_RUN_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])]dnl
 [AS_IF([ac_fn_[]_AC_LANG_ABBREV[]_try_run "$LINENO"], [$2], [$3])
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest$ac_exeext[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl
+  conftest.$ac_objext conftest.beam \
+  conftest$ac_exeext[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl
 ])# _AC_RUN_IFELSE
 
 # AC_RUN_IFELSE(PROGRAM,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 085c9d1..4c29a6e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -168,7 +168,6 @@ AUTOCONF_FILES = $(autoconfdir)/general.m4 \
 		 $(autoconfdir)/functions.m4 \
 		 $(autoconfdir)/lang.m4 \
 		 $(autoconfdir)/c.m4 \
-		 $(autoconfdir)/erlang.m4 \
 		 $(autoconfdir)/fortran.m4 \
 		 $(autoconfdir)/headers.m4 \
 		 $(autoconfdir)/libs.m4 \
diff --git a/tests/erlang.at b/tests/erlang.at
index f3ced24..424d071 100644
--- a/tests/erlang.at
+++ b/tests/erlang.at
@@ -25,190 +25,104 @@ AT_BANNER([Erlang low level compiling and utility macros.])
 # primitive, so check those first.
 
 
-# AT_SETUP_ERLANG(title)
-# ----------------------
-# Setup a test group for Erlang, named TITLE.
-m4_define([AT_SETUP_ERLANG],
-[AT_SETUP([$1])
-AT_KEYWORDS([Erlang])
-found_erl=no
-found_erlc=no
-_AS_PATH_WALK([], [
-if AS_EXECUTABLE_P(["$as_dir/erl"]); then found_erl=yes; fi
-if AS_EXECUTABLE_P(["$as_dir/erlc"]); then found_erlc=yes; fi
-if test "${found_erl}${found_erlc}" = "yesyes"; then break; fi
-])
-AT_SKIP_IF([test "$found_erl$found_erlc" != "yesyes"])])
-
-
 ## ----------------- ##
 ## Erlang Compiler.  ##
 ## ----------------- ##
 
-AT_SETUP_ERLANG([Erlang])
-
-AT_DATA([configure.ac],
-[[AC_INIT
-AC_ERLANG_NEED_ERL
-AC_ERLANG_NEED_ERLC
+AT_CHECK_MACRO([Erlang],
+[[AC_ERLANG_PATH_ERL([not found])
+AC_ERLANG_PATH_ERLC([not found])
+if test "$ERL" = "not found" -o "$ERLC" = "not found"; then exit 77; fi
 AC_LANG([Erlang])
 ## Can't compile, but can run an Erlang module:
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [halt(0)])],
-              [AC_MSG_RESULT([ok])
-               AC_MSG_ERROR([compiling Erlang program should fail])],
-              [AC_MSG_RESULT([failed])])
+		  [AC_MSG_RESULT([ok])
+		   AC_MSG_ERROR([compiling Erlang program should fail])],
+		  [AC_MSG_RESULT([failed])])
 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [halt(0)])],
-              [AC_MSG_RESULT([ok])],
-              [AC_MSG_RESULT([failed])
-               AC_MSG_ERROR([could not run test program])])
-]])
-
-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE([-q])
-
-AT_CLEANUP
-
+	      [AC_MSG_RESULT([ok])],
+	      [AC_MSG_RESULT([failed])
+	       AC_MSG_ERROR([could not run test program])])
+]],
+[AT_KEYWORDS([Erlang])])
 
-## ----------------------- ##
-## Erlang path detection.  ##
-## ----------------------- ##
 
-AT_SETUP_ERLANG([AC_ERLANG_CHECK_LIB])
+## ---------------------- ##
+## Erlang lib detection.  ##
+## ---------------------- ##
 
-AT_DATA([configure.ac],
-[[AC_INIT
-AC_ERLANG_NEED_ERL
-AC_ERLANG_NEED_ERLC
+AT_CHECK_MACRO([AC_ERLANG_CHECK_LIB],
+[[AC_ERLANG_PATH_ERL([not found])
+AC_ERLANG_PATH_ERLC([not found])
+if test "$ERL" = "not found" -o "$ERLC" = "not found"; then exit 77; fi
 AC_ERLANG_CHECK_LIB([stdlib],
-                    [AC_MSG_RESULT([ok])],
-                    [AC_MSG_RESULT([failed])])
-AC_CONFIG_FILES([dir])
-AC_OUTPUT
-]])
-
-AT_DATA([dir.in],
-...@erlang_lib_dir_stdlib@
-]])
-
-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE([-q])
-
-dir=`cat dir`
-rm -f dir
-AT_CHECK([test "$dir" = "not found" || test -d "$dir"])
-
-AT_CLEANUP
+		    [AC_MSG_RESULT([ok])],
+		    [AC_MSG_RESULT([failed])])
+## Test that the lib path detection really detected a directory:
+test "$ERLANG_LIB_DIR_stdlib" = "not found" || test -d "$ERLANG_LIB_DIR_stdlib"
+]],
+[AT_KEYWORDS([Erlang])])
 
 
 ## --------------------------- ##
 ## Erlang root dir detection.  ##
 ## --------------------------- ##
 
-AT_SETUP_ERLANG([AC_ERLANG_SUBST_ROOT_DIR])
-
-AT_DATA([configure.ac],
-[[AC_INIT
-AC_ERLANG_NEED_ERL
-AC_ERLANG_NEED_ERLC
+AT_CHECK_MACRO([AC_ERLANG_SUBST_ROOT_DIR],
+[[AC_ERLANG_PATH_ERL([not found])
+AC_ERLANG_PATH_ERLC([not found])
+if test "$ERL" = "not found" -o "$ERLC" = "not found"; then exit 77; fi
 AC_ERLANG_SUBST_ROOT_DIR
-AC_CONFIG_FILES([dir])
-AC_OUTPUT
-]])
-
-AT_DATA([dir.in],
-...@erlang_root_dir@
-]])
-
-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE([-q])
-
-dir=`cat dir`
-rm -f dir
-AT_CHECK([test -d "$dir"])
-
-AT_CLEANUP
+## Test that the root path detection really detected a directory:
+test -d "$ERLANG_ROOT_DIR"
+]],
+[AT_KEYWORDS([Erlang])])
 
 
 ## -------------------------- ##
 ## Erlang lib dir detection.  ##
 ## -------------------------- ##
 
-AT_SETUP_ERLANG([AC_ERLANG_SUBST_LIB_DIR])
-
-AT_DATA([configure.ac],
-[[AC_INIT
-AC_ERLANG_NEED_ERL
-AC_ERLANG_NEED_ERLC
+AT_CHECK_MACRO([AC_ERLANG_SUBST_LIB_DIR],
+[[AC_ERLANG_PATH_ERL([not found])
+AC_ERLANG_PATH_ERLC([not found])
+if test "$ERL" = "not found" -o "$ERLC" = "not found"; then exit 77; fi
 AC_ERLANG_SUBST_LIB_DIR
-AC_CONFIG_FILES([dir])
-AC_OUTPUT
-]])
-
-AT_DATA([dir.in],
-...@erlang_lib_dir@
-]])
-
-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE([-q])
-
-dir=`cat dir`
-rm -f dir
-AT_CHECK([test -d "$dir"])
-
-AT_CLEANUP
-
-
-## ------------------------------- ##
-## Erlang installation detection.  ##
-## ------------------------------- ##
-
-AT_CHECK_MACRO([AC_ERLANG_SUBST_INSTALL_LIB_DIR], [],
+## Test that the lib path detection really detected a directory:
+test -d "$ERLANG_LIB_DIR"
+]],
 [AT_KEYWORDS([Erlang])])
 
 
-## ------------------------------- ##
-## Erlang installation detection.  ##
-## ------------------------------- ##
-
-AT_SETUP([AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR])
-AT_KEYWORDS([Erlang])
+## ----------------------------------- ##
+## Erlang install base dir detection.  ##
+## ----------------------------------- ##
 
-AT_DATA([configure.ac],
-[[AC_INIT
-AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR([test_blah], [1.24-b])
-AC_CONFIG_FILES([dir])
-AC_OUTPUT
-]])
+AT_CHECK_MACRO([AC_ERLANG_SUBST_INSTALL_LIB_DIR],
+	       [AT_KEYWORDS([Erlang])])
 
-AT_DATA([dir.in],
-...@erlang_install_lib_dir_test_blah@
-]])
 
-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE([-q])
+## ---------------------------------- ##
+## Erlang install lib dir detection.  ##
+## ---------------------------------- ##
 
-dir=`cat dir`
-subdir=`AS_BASENAME([$dir])`
-rm -f dir
-AT_CHECK([test "$subdir" = "test_blah-1.24-b"])
-
-AT_CLEANUP
+AT_CHECK_MACRO([AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR],
+[[AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR([test_blah], [1.24-b])
+## Test that the generated directory name is well-formed:
+m4_pattern_allow([^AS_BASENAME$])
+test `AS_BASENAME([$ERLANG_INSTALL_LIB_DIR_test_blah])` = "test_blah-1.24-b"
+]],
+[AT_KEYWORDS([Erlang])])
 
 
 ## -------------------------- ##
 ## Erlang version detection.  ##
 ## -------------------------- ##
 
-AT_SETUP_ERLANG([AC_ERLANG_SUBST_ERTS_VER])
-
-AT_DATA([configure.ac],
-[[AC_INIT
-AC_ERLANG_NEED_ERL
-AC_ERLANG_NEED_ERLC
+AT_CHECK_MACRO([AC_ERLANG_SUBST_ERTS_VER],
+[[AC_ERLANG_PATH_ERL([not found])
+AC_ERLANG_PATH_ERLC([not found])
+if test "$ERL" = "not found" -o "$ERLC" = "not found"; then exit 77; fi
 AC_ERLANG_SUBST_ERTS_VER
-]])
-
-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE([-q])
-
-AT_CLEANUP
+]],
+[AT_KEYWORDS([Erlang])])
diff --git a/tests/local.at b/tests/local.at
index 8a81835..32ba97e 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -296,7 +296,8 @@ if test -f state-env.before && test -f state-env.after; then
       [(exec_)?prefix|DEFS|CONFIG_STATUS],
       [CC|CFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
       [ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
-      [ERLANG_INSTALL_LIB_DIR|OBJC|OBJCPP|OBJCFLAGS],
+      [ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
+      [OBJC|OBJCPP|OBJCFLAGS],
       [OPENMP_CFLAGS],
       [LIBS|LIB@&t...@objs|LTLIBOBJS|LDFLAGS],
       [INSTALL(_(DATA|PROGRAM|SCRIPT))?],

Reply via email to