On Tuesday 21 July 2009 20:23:59 Eric Blake wrote:
> According to Romain Lenglet on 7/20/2009 10:33 PM:
> > Hi,
> >
> > The attached patch adds tests for the macros in erlang.m4.
>
> 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 haven't been able to use AT_CHECK_MACRO for testing most of the
> > macros, because most macros fail in AT_CHECK_ENV, for reasons I don't
> > yet understand. It seems that every time a test that runs Erlang code is
> > peformed, AT_CHECK_ENV fails, so it may be a bug in the Erlang language
> > support. How can I get more information about what is going on with
> > AT_CHECK_ENV?
>
> AT_CHECK_ENV is defined in tests/local.at; it's job is to exempt a number
> of environment variables that don't fit autoconf namespace rules but do
> get set by autoconf.  My guess is that the list just needs to be made
> larger; you should be able to inspect the testsuite directory after a
> failed tests to compare clean-state-env.before and clean-state-env.after
> to see what environment variables are being set by Erlang support (and
> whether we should rename them into the autoconf namespace or exempt them).

OK. I will have to spend more time to check that.
I attached a new patch which takes into account your other comments below.

> > Also, those tests will fail if Erlang is not installed. I could use
> > AT_SKIP_IF for each test group to don't perform a test group, but it's
> > tedious. Is there an equivalent to AT_SKIP_IF that works for a whole
> > test group category (the whole erlang.at file)?
>
> Yes - the trick is to write a wrapper macro:
>
> m4_define([AT_CHECK_ERLANG],
> [AT_KEYWORDS([Erlang])
> AT_SKIP_IF([<erlang not found>])
> AT_CHECK($@)])

OK. Done.

> then use AT_CHECK_ERLANG through the rest of erlang.at.  I can't apply the
> patch until we cater to the fact that Erlang is not yet universal.
>
> > +   Add autotests for Erlang macros.
> > +   * tests/erlang.at: Added tests for all macros in erlang.m4.
> > +   * tests/Makefile.am: Added erlang.at.
> > +   * tests/suite.at: Likewise.
> > +   * tests/compile.at: Added test for extension of Erlang files.
>
> Given the regressions that Erlang has had in the past, I'd like to include
> this in 2.64, but my time schedule is that I either release it by this
> Saturday, or it waits till mid-August after my vacation.

Anyway the main purpose of autotests is to prevent regressions?
My patch does not add any feature, and I have not found any bug in the latest 
version of the repository.
So it may be OK to add the tests after releasing?

> > +** The following macros are now covered by autotests:
> > +   AC_ERLANG_CHECK_LIB, AC_ERLANG_SUBST_ROOT_DIR,
> > +   AC_ERLANG_SUBST_LIB_DIR, AC_ERLANG_SUBST_INSTALL_LIB_DIR,
> > +   AC_ERLANG_SUBST_ERTS_VER, and the macros for tests in Erlang
>
> How about we just condense this to:
>
> The autoconf testsuite now validates all Erlang macros.

OK. Done.

> > +++ b/tests/compile.at
> > @@ -43,9 +43,13 @@ AC_LANG_PUSH(C++)
> >  # C++ C C
> >  AC_LANG(C++)
> >  # C++ C C
> > +AC_LANG_PUSH(Erlang)
> > +# Erlang C++ C C
>
> Am I correct that this test has no problems regardless of whether Erlang
> is present?

Yes, it's OK.

> > +++ b/tests/erlang.at
> > @@ -0,0 +1,178 @@
> > +#                                                  -*- Autotest -*-
> > +
> > +AT_BANNER([Erlang low level compiling and utility macros.])
> > +
> > +# Copyright (C) 2000, 2001, 2003, 2008 Free Software Foundation, Inc.
>
> Fix the copyright years - it is a new file, and needs only 2009.

OK. Done.

> > +AT_SETUP([Erlang])
> > +
> > +AT_DATA([configure.ac],
> > +[[AC_INIT
> > +AC_ERLANG_NEED_ERL
> > +AC_ERLANG_NEED_ERLC
> > +AC_LANG(Erlang)
>
> Let's get in the habit of following our documentation: AC_LANG([Erlang])

OK. Done in erlang.at and also in compile.at for other cases I have found.

Thanks,
--
Romain Lenglet
diff --git a/ChangeLog b/ChangeLog
index e1a6494..9334e21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-07-20  Romain Lenglet  <[email protected]>
+
+	Add autotests for Erlang macros.
+	* tests/erlang.at: Added tests for all macros in erlang.m4.
+	* tests/Makefile.am: Added erlang.at.
+	* tests/suite.at: Likewise.
+	* tests/compile.at: Added test for extension of Erlang files.
+
 2009-07-16  Eric Blake  <[email protected]>
 
 	Don't hide leading space in autom4te --trace output.
diff --git a/NEWS b/NEWS
index ef67c77..ec63834 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,8 @@ GNU Autoconf NEWS - User visible changes.
    m4_argn  m4_copy_force  m4_default_nblank  m4_default_nblank_quoted
    m4_ifblank  m4_ifnblank  m4_rename_force
 
+** The autoconf testsuite now validates all Erlang macros.
+
 * Major changes in Autoconf 2.63b (2009-03-31) [beta]
   Released by Eric Blake, based on git versions 2.63.*.
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f07c553..085c9d1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -100,7 +100,7 @@ TESTSUITE_HAND_AT = \
 	suite.at \
 	m4sugar.at m4sh.at autotest.at \
 	base.at tools.at torture.at \
-	compile.at c.at fortran.at \
+	compile.at c.at erlang.at fortran.at \
 	semantics.at \
 	autoscan.at \
 	foreign.at
@@ -168,6 +168,7 @@ 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/compile.at b/tests/compile.at
index 20398fb..9675539 100644
--- a/tests/compile.at
+++ b/tests/compile.at
@@ -35,23 +35,27 @@ AT_SETUP([[AC_LANG, AC_LANG_PUSH & AC_LANG_POP]])
 AT_DATA([configure.ac],
 [[AC_INIT
 # C
-AC_LANG(C)
+AC_LANG([C])
 # C
-AC_LANG_PUSH(C)
+AC_LANG_PUSH([C])
 # C C
-AC_LANG_PUSH(C++)
+AC_LANG_PUSH([C++])
 # C++ C C
-AC_LANG(C++)
+AC_LANG([C++])
 # C++ C C
-AC_LANG_PUSH(Fortran 77)
-# F77 C++ C C
-AC_LANG_POP(Fortran 77)
+AC_LANG_PUSH([Erlang])
+# Erlang C++ C C
+AC_LANG_PUSH([Fortran 77])
+# F77 Erlang C++ C C
+AC_LANG_POP([Fortran 77])
+# Erlang C++ C C
+AC_LANG_POP([Erlang])
 # C++ C C
-AC_LANG(C++)
+AC_LANG([C++])
 # C++ C C
-AC_LANG_POP(C++)
+AC_LANG_POP([C++])
 # C C
-AC_LANG_POP(C)
+AC_LANG_POP([C])
 # C
 ]])
 
@@ -62,7 +66,9 @@ c
 c
 cpp
 cpp
+erl
 f
+erl
 cpp
 cpp
 c
@@ -243,16 +249,16 @@ AT_DATA([configure.ac],
 AC_PROG_CC
 AC_PROG_CXX
 
-AC_LANG_PUSH(C)
+AC_LANG_PUSH([C])
 AC_MSG_CHECKING([a simple C program that is not valid C++])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([enum a { A, B, C };
 				    enum a f(enum a in) { return in++; }], [])],
 		  [AC_MSG_RESULT([ok])],
 		  [AC_MSG_RESULT([failed])
 		   AC_MSG_ERROR([could not compile test program])])
-AC_LANG_POP(C)
+AC_LANG_POP([C])
 
-AC_LANG_PUSH(C++)
+AC_LANG_PUSH([C++])
 AC_MSG_CHECKING([a simple C++ program that is not valid C])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([class A {};], [])],
 		  [AC_MSG_RESULT([ok])],
@@ -260,7 +266,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([class A {};], [])],
 		   AC_MSG_ERROR([could not compile test program])])
 
 AC_CHECK_HEADER([cstring])
-AC_LANG_POP(C++)
+AC_LANG_POP([C++])
 ]])
 
 AT_CHECK_AUTOCONF
diff --git a/tests/erlang.at b/tests/erlang.at
new file mode 100644
index 0000000..5dbdc19
--- /dev/null
+++ b/tests/erlang.at
@@ -0,0 +1,194 @@
+#							-*- Autotest -*-
+
+AT_BANNER([Erlang low level compiling and utility macros.])
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+
+# Since the macros which compile are required by most tests, check
+# them first.  But remember that looking for a compiler is even more
+# primitive, so check those first.
+
+
+m4_define([AT_CHECK_ERLANG],
+[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"])
+AT_CHECK($@)])
+
+
+## ----------------- ##
+## Erlang Compiler.  ##
+## ----------------- ##
+
+AT_SETUP([Erlang])
+AT_CHECK_ERLANG
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ERLANG_NEED_ERL
+AC_ERLANG_NEED_ERLC
+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_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
+
+
+## ----------------------- ##
+## Erlang path detection.  ##
+## ----------------------- ##
+
+AT_SETUP([AC_ERLANG_CHECK_LIB])
+AT_CHECK_ERLANG
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ERLANG_NEED_ERL
+AC_ERLANG_NEED_ERLC
+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
+
+
+AT_SETUP([AC_ERLANG_SUBST_ROOT_DIR])
+AT_CHECK_ERLANG
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ERLANG_NEED_ERL
+AC_ERLANG_NEED_ERLC
+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
+
+
+AT_SETUP([AC_ERLANG_SUBST_LIB_DIR])
+AT_CHECK_ERLANG
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ERLANG_NEED_ERL
+AC_ERLANG_NEED_ERLC
+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
+
+
+AT_CHECK_MACRO([AC_ERLANG_SUBST_INSTALL_LIB_DIR])
+
+
+AT_SETUP([AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR([test_blah], [1.24-b])
+AC_CONFIG_FILES([dir])
+AC_OUTPUT
+]])
+
+AT_DATA([dir.in],
+...@erlang_install_lib_dir_test_blah@
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+dir=`cat dir`
+subdir=`AS_BASENAME([$dir])`
+rm -f dir
+AT_CHECK([test "$subdir" = "test_blah-1.24-b"])
+
+AT_CLEANUP
+
+
+AT_SETUP([AC_ERLANG_SUBST_ERTS_VER])
+AT_CHECK_ERLANG
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ERLANG_NEED_ERL
+AC_ERLANG_NEED_ERLC
+AC_ERLANG_SUBST_ERTS_VER
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+AT_CLEANUP
diff --git a/tests/suite.at b/tests/suite.at
index ff0347e..7302b60 100644
--- a/tests/suite.at
+++ b/tests/suite.at
@@ -52,6 +52,7 @@ m4_include([c.at])
 m4_include([acc.at])
 m4_include([fortran.at])
 m4_include([acfortran.at])
+m4_include([erlang.at])
 
 # Checking that AC_CHECK_FOO macros work properly.
 m4_include([semantics.at])

Reply via email to