Compatibility with Autoconf
Syntax of GNU Autoconf Testuites
autofonce
can only read testsuites that are in a subset of what
GNU Autoconf allows. Indeed, testsuites for Autoconf are shell scripts
with M4 macros inside. Instead, autofonce
can only read a subset
of known builtin M4 macros with a simpler syntax.
For the syntax, autofonce
has the following limitations:
Macros should appear at toplevel, or within brackets inside other macros.
Scripts commands are only accepted within a test sequence (i.e. after
AT_SETUP
and beforeAT_CLEANUP
), and should never exceed one line.
See the next section for advices on how to translate existing testsuites to
be used by autofonce
.
The following macros are understood at toplevel by autofonce
:
AT_COPYRIGHT([copyright])
: copyright notice of the testsuiteAT_INIT([testsuite-name])
: name of the testsuiteAT_COLOR_TESTS
: discardedAT_TESTED([executables])
: list of space separated commandsAT_BANNER([banner])
: a banner separating testsm4_include([file.at])
: include macros from a file.autofonce
will try to find the file withing a directorytestsuite.src
in the same directory.AT_SETUP([test-name])
: beginning of a test
The following macros are understood within a test (after AT_SETUP
):
AT_KEYWORDS([keywords])
: list of space separating keywords to select the testAT_SKIP_IF([shell-condition])
: currently,autofonce
always skip such tests to avoid running the condition.AT_DATA([file-name], [file-content])
: create the corresponding fileAT_CAPTURE_FILE([file-name])
: capture file in case of failureAT_CHECK([shell-command], [retcode], [stdout], [stderr], [run-if-fail], [run-if-pass])
: all arguments are optional except for the first one. run-if-fail and run-if-pass should always be specified within brackets (as otherwise, brackets within them would be removed).AT_CLEANUP
: end of test
Advices to port testsuites to autofonce
In general, using shell outside of macros should be
avoided. autofonce
has some support for single line shell
commands, and if ... ; then
/ else
/ fi
on different lines.
Toplevel shell commands: such commands should be completely avoided
Shell commands within tests: use
AT_CHECK
macros to execute such commands. For example:sort < file1 > file2
should be translated into:
AT_CHECK([sort < file1 > file2])
Shell conditional execution. use
AT_CHECK
and its run-of-fail and run-if-pass parts to encodeif ... then ... else
.For example:
if test "x" != "y" ; then ...THEN_MACROS... else ...ELSE_MACROS... fi
should be translated into:
AT_CHECK([test "x" != "y"], [1], [], [], [ ...THEN_MACROS... ] , [ ...ELSE_MACROS... ])
Pay attention to the fact that the order of fail/pass is the opposite for
if-then-else
andAT_CHECK
, so we have to expect a result of[1]
(failedtest
) to keep the same order.