I squashed in the attached patch, and I'm going to push it after you confirm that make check still passes with Erlang installed. distcheck is still running.

In particular, I made the testsuite run also if Erlang is not found, to
check that it skips the test.

I also removed your attribution in specific.m4 on the grounds that it is probably going to grow (I may do JUnit) and that you already have it in lib/autoconf/erlang.m4. :-)

Can we make this code addition conditional to test suites in which
AT_CHECK_EUNIT is used?  (Diversions ought to help here.)
We don't want unnecessary code expansions.

I don't see how to do that easily, since AT_CONFIG_TESTDIR doesn't parse the
test suite at all.

I did that, conditional on the definition of AC_ERLANG_PATH_ERL.

+AT_CHECK(["$ERLC" $ERLCFLAGS -b beam $1.erl])
Does that never produce any output?  Wow.

If compilation is fine, no output is produced. But it outputs something in
case of warnings or errors, which in this case indicates that the test-spec
has an invalid syntax, which should fail the test. I think that this is a
legitimate use of AT_CHECK?

Yes, it's okay.

Paolo
2009-08-01  Paolo Bonzini  <[email protected]>

        * lib/autoconf/autotest.m4 (AC_CONFIG_TESTDIR): Make definitions
        of ERL/ERLC/ERLCFLAGS optional.
        * tests/autotest.at: Remove pkg indirection.  Cosmetic fixes to
        configure.ac.  Always run testsuite and check for skipped tests.

diff --git a/ChangeLog b/ChangeLog
index 2e59a58..f6c4918 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,7 @@
 2009-08-01  Romain Lenglet  <[email protected]>
 
-       * lib/autotest/specific.m4 (AT_CHECK_EUNIT): New file defining new
-       AT_CHECK_EUNIT macro.
-       * lib/autotest/Makefile.am (dist_autotestlib_DATA): Add
-       specific.m4.
+       * lib/autotest/specific.m4 (AT_CHECK_EUNIT): New file.
+       * lib/autotest/Makefile.am (dist_autotestlib_DATA): Add specific.m4.
        * lib/autoconf/autotest.m4 (AC_CONFIG_TESTDIR): Add definitions of
        variables used by AT_CHECK_EUNIT macro: ERL, ERLC, ERLCFLAGS.
        * tests/autotest.at (Erlang Eunit unit tests): Add test for macro
diff --git a/lib/autoconf/autotest.m4 b/lib/autoconf/autotest.m4
index a962880..29dffac 100644
--- a/lib/autoconf/autotest.m4
+++ b/lib/autoconf/autotest.m4
@@ -84,14 +84,14 @@ at_top_builddir=\$at_top_build_prefix
 AUTOTEST_PATH='m4_default([$2], [$1])'
 
 SHELL=\${CONFIG_SHELL-'$SHELL'}
-
-# Required to run EUnit unit tests.
+m4_provide_if([AC_ERLANG_PATH_ERL], [
 ERL='$ERL'
 ERLC='$ERLC'
 ERLCFLAGS='$ERLCFLAGS'
+])dnl
 ATEOF
 ],
-[ERL="$ERL"
+[m4_provide_if([AC_ERLANG_PATH_ERL], [ERL="$ERL"
 ERLC="$ERLC"
-ERLCFLAGS="$ERLCFLAGS"])
-])# AC_CONFIG_TESTDIR
+ERLCFLAGS="$ERLCFLAGS"
+])])])# AC_CONFIG_TESTDIR
diff --git a/lib/autotest/specific.m4 b/lib/autotest/specific.m4
index ec42c35..df32cfe 100644
--- a/lib/autotest/specific.m4
+++ b/lib/autotest/specific.m4
@@ -44,8 +44,6 @@ m4_define([_AT_COPYRIGHT_YEARS],
 # the non-data portions to the data portions.)  If your modification has
 # such potential, you must delete any notice of this special exception
 # to the GPL from your modified version.
-#
-# Written by Romain Lenglet
 
 
 ## ------------------------ ##
@@ -62,7 +60,7 @@ m4_define([_AT_COPYRIGHT_YEARS],
 # debugging.
 # An Erlang/OTP version which contains the eunit library must be
 # installed, in order to execute this macro in a test suite.  The ERL,
-# ERLC, and ERLCFLAGS variables must be defined in configure.ac,
+# ERLC, and ERLCFLAGS variables must be defined in atconfig,
 # typically by using the AC_ERLANG_PATH_ERL and AC_ERLANG_PATH_ERLC
 # Autoconf macros.
 _AT_DEFINE_SETUP([AT_CHECK_EUNIT],
diff --git a/tests/autotest.at b/tests/autotest.at
index 13e2e5d..03968f7 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -1438,68 +1438,84 @@ AT_CLEANUP
 AT_SETUP([Erlang Eunit unit tests])
 AT_KEYWORDS([Erlang])
 
-mkdir pkg
-mkdir pkg/s pkg/t
-AT_DATA([pkg/configure.ac], [[AC_INIT
+mkdir s t
+AT_DATA([configure.ac], [[AC_INIT
 AC_ERLANG_PATH_ERL([not found])
 AC_ERLANG_PATH_ERLC([not found])
-if test "$ERL" = "not found" || test "$ERLC" = "not found"; then exit 77; fi
-AC_ERLANG_CHECK_LIB([eunit], [], [exit 77])
+if test "$ERL" = "not found" || test "$ERLC" = "not found"; then
+  HAVE_ERLANG=no
+  HAVE_EUNIT=no
+else
+  HAVE_ERLANG=yes
+  AC_ERLANG_CHECK_LIB([eunit], [HAVE_EUNIT=yes], [HAVE_EUNIT=no])
+fi
+AC_SUBST([HAVE_ERLANG])
+AC_SUBST([HAVE_EUNIT])
+
 AC_CONFIG_TESTDIR([t])
-AC_CONFIG_FILES([s/compile])
+AC_CONFIG_FILES([s/compile], [chmod +x s/compile])
+AC_CONFIG_FILES([erlang.conf])
 AC_OUTPUT
 ]])
 cp "$abs_top_srcdir/build-aux/install-sh" pkg
 
+# File to pass info back to us
+AT_DATA([erlang.conf.in],
+[[have_erla...@have_erlang@
+have_eun...@have_eunit@
+]])
+
 # Erlang module to test:
-AT_DATA([pkg/s/testme.erl],
+AT_DATA([s/testme.erl],
 [[-module(testme).
 -export([foo/1]).
 foo(1) -> one;
 foo(2) -> two;
 foo(_) -> other.
 ]])
+
 # Corresponding Eunit unit test module:
-AT_DATA([pkg/s/testme_tests.erl],
+AT_DATA([s/testme_tests.erl],
 [[-module(testme_tests).
 -include_lib("eunit/include/eunit.hrl").
 foo_one_test() -> ?assertEqual(one, testme:foo(1)).
 foo_two_test() -> ?assertEqual(two, testme:foo(2)).
 foo_other_test() -> ?assertEqual(other, testme:foo(42)).
 ]])
+
 # Compilation script:
-AT_DATA([pkg/s/compile.in],
+AT_DATA([s/compile.in],
 [["@ERLC@" -b beam testme.erl testme_tests.erl
 ]])
 
-cd pkg
-AT_CHECK_AUTOCONF
-cd ..
-
-
 AT_CHECK_AT_PREP([suite],
 [[AT_INIT([suite to check EUnit integration])
 AT_SETUP([my only test])
 AT_CHECK_EUNIT([my_testsuite], [{module, testme}],
               [-pa "${abs_top_builddir}/s"])
 AT_CLEANUP
-]], [], [], [], [pkg/t])
+]], [], [], [], [t])
 
-cd pkg
+AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-cd ..
+. ./erlang.conf
 
-AT_CHECK([grep '^ERL='\''.*'\' pkg/t/atconfig], [], [ignore])
-AT_CHECK([grep '^ERLC='\''.*'\' pkg/t/atconfig], [], [ignore])
-AT_CHECK([grep '^ERLCFLAGS='\''.*'\' pkg/t/atconfig], [], [ignore])
+AT_CHECK([grep '^ERL='\''.*'\' t/atconfig], [], [ignore])
+AT_CHECK([grep '^ERLC='\''.*'\' t/atconfig], [], [ignore])
+AT_CHECK([grep '^ERLCFLAGS='\''.*'\' t/atconfig], [], [ignore])
 
-cd pkg/s
-chmod +x "./compile"
-AT_CHECK([$CONFIG_SHELL ./compile])
-cd ../..
+if test "$HAVE_ERLANG" = yes; then
+  AT_CHECK([cd s && $CONFIG_SHELL ./compile])
+fi
 
-cd pkg/t
-AT_CHECK([$CONFIG_SHELL ./suite], [0], [ignore])
-cd ../..
+AT_CHECK([cd t && $CONFIG_SHELL ./suite], [], [ignore])
+
+if test "$HAVE_EUNIT" = yes; then
+  AT_CHECK([grep 1.*successful t/suite.log], [], [ignore])
+  AT_CHECK([grep 0.*skipped t/suite.log], [], [ignore])
+else
+  AT_CHECK([grep 1.*skipped t/suite.log], [], [ignore])
+  AT_CHECK([grep 0.*successful t/suite.log], [], [ignore])
+fi
 
 AT_CLEANUP

Reply via email to