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 before AT_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 testsuite

  • AT_INIT([testsuite-name]): name of the testsuite

  • AT_COLOR_TESTS: discarded

  • AT_TESTED([executables]): list of space separated commands

  • AT_BANNER([banner]): a banner separating tests

  • m4_include([file.at]): include macros from a file. autofonce will try to find the file withing a directory testsuite.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 test

  • AT_SKIP_IF([shell-condition]): currently, autofonce always skip such tests to avoid running the condition.

  • AT_DATA([file-name], [file-content]): create the corresponding file

  • AT_CAPTURE_FILE([file-name]): capture file in case of failure

  • AT_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 encode if ... 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 and AT_CHECK, so we have to expect a result of [1] (failed test) to keep the same order.