autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dependency injection and unit testing of M4 macros


From: tsuna
Subject: Dependency injection and unit testing of M4 macros
Date: Wed, 10 Sep 2008 10:39:59 +0200

Hi list,
I'm maintaining a set of M4 macros and want to write regression tests
as people report bugs.  Running end-to-end tests where I generate a
configure script and run it and see if it works as expected is taking
too long (I already do that by re-using autoconf's own testsuite and
it takes 20 minutes to run 40 tests on my recent Mac).  I'd like to
use some dependency injection in order to cut the cost of some of the
tests.  The idea is that I have this:

AC_DEFUN([MY_MACRO],
[AC_REQUIRE([SOME_DEP])dnl
# some code here
_MY_HELPER_MACRO([whatever])
# some more code here
])

where both SOME_DEP and _MY_HELPER_MACRO are defined in the same file,
mypkg.m4, which is automatically m4_include'd by the generated
aclocal.m4.

I tried to use m4_rename like so:
m4_rename([SOME_DEP], [SAVED_SOME_DEP])dnl <-- this is line 300
AC_DEFUN([SOME_DEP], [echo hooked cheap dep])
# my test with MY_MACOR here
m4_rename([SAVED_SOME_DEP], [SOME_DEP])


but I always get a
../../tests/testsuite.at:300: error: m4_defn: undefined macro: SOME_DEP
../../tests/testsuite.at:300: the top level
autom4te: /usr/bin/gm4 failed with exit status: 1

AC_DEFUN == m4_defun, right?  And m4_defun does a m4_define, so what
am I doing wrong?

-- 
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory




reply via email to

[Prev in Thread] Current Thread [Next in Thread]