(AT_CLEANUP_FILES): New macros.
(AT_SETUP, AT_CHECK, AT_CLEANUP): Use them.
(AT_CHECK): Fix a use of at_verbose.
* tests/atspecific.m4 (AT_CHECK_AUTOCONF, AT_CHECK_AUTOHEADER)
(AT_CHECK_CONFIGURE): New macros.
+2000-11-23 Akim Demaille <akim@epita.fr>
+
+ * tests/atgeneral.m4 (AT_CLEAN_FILE_IFELSE, AT_CLEANUP_FILE)
+ (AT_CLEANUP_FILES): New macros.
+ (AT_SETUP, AT_CHECK, AT_CLEANUP): Use them.
+ (AT_CHECK): Fix a use of at_verbose.
+ * tests/atspecific.m4 (AT_CHECK_AUTOCONF, AT_CHECK_AUTOHEADER)
+ (AT_CHECK_CONFIGURE): New macros.
+
2000-11-23 Akim Demaille <akim@epita.fr>
* tests/atgeneral.m4 (AT_INIT) <at_verbose>: Be a :/echo variable.
# The group is testing what DESCRIPTION says.
AT_DEFINE([AT_SETUP],
[AT_DEFINE([AT_ordinal], m4_eval(AT_ordinal + 1))
-m4_pushdef([AT_data_files], )
-m4_pushdef([AT_data_expout], )
-m4_pushdef([AT_data_experr], )
+m4_pushdef([AT_data_files], [stdout stderr ])
m4_divert_pop()dnl
AT_ordinal )
dnl Here will be inserted the `rm' corresponding to AT_CLEANUP.
])
+# AT_CLEANUP_FILE_IFELSE(FILE, IF-REGISTERED, IF-NOT-REGISTERED)
+# --------------------------------------------------------------
+AT_DEFINE([AT_CLEANUP_FILE_IFELSE],
+[ifelse(m4_regexp(AT_data_files, m4_patsubst([ $1 ], [\([\[\]*.]\)], [\\\1])),
+ -1,
+ [$3], [$2])])
+
+
+# AT_CLEANUP_FILE(FILE)
+# ---------------------
+# Register FILE for AT_CLEANUP.
+AT_DEFINE([AT_CLEANUP_FILE],
+[AT_CLEANUP_FILE_IFELSE([$1], [],
+ [m4_append([AT_data_files], [$1 ])])])
+
+
+# AT_CLEANUP_FILES(FILES)
+# -----------------------
+# Declare a list of FILES to clean.
+AT_DEFINE([AT_CLEANUP_FILES],
+[m4_foreach([AT_File], m4_quote(m4_patsubst([$1], [ *], [,])),
+ [AT_CLEANUP_FILE(AT_File)])])
+
+
# AT_CLEANUP(FILES)
# -----------------
# Complete a group of related tests, recursively remove those FILES
# created within the test. There is no need to list stdout, stderr,
# nor files created with AT_DATA.
AT_DEFINE([AT_CLEANUP],
-[ $at_traceoff
+[AT_CLEANUP_FILES([$1])dnl
+ $at_traceoff
)
at_status=$?
at_test_count=`expr 1 + $at_test_count`
if $at_stop_on_error && test -n "$at_failed_list"; then :; else
- rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
+ rm -rf AT_data_files
fi
;;
m4_divert(1)[]dnl
- rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
+ rm -rf AT_data_files
m4_undivert(2)[]dnl
-m4_popdef([AT_data_experr])dnl
-m4_popdef([AT_data_expout])dnl
m4_popdef([AT_data_files])dnl
m4_divert_push([KILL])dnl
])# AT_CLEANUP
# This macro is not robust to active symbols in CONTENTS *on purpose*.
# If you don't want CONTENT to be evaluated, quote it twice.
AT_DEFINE([AT_DATA],
-[AT_DEFINE([AT_data_files], AT_data_files[ ]$1)
+[AT_CLEANUP_FILES([$1])dnl
cat >$1 <<'_ATEOF'
$2[]_ATEOF
])
dnl Restore stdout to fd1 and stderr to fd2.
exec 1>&5 2>&6
dnl If not verbose, neutralize the output of diff.
- test $at_verbose = echo && exec 1>/dev/null 2>/dev/null
+ test $at_verbose = : && exec 1>/dev/null 2>/dev/null
at_failed=false;
m4_case([$4],
ignore, [$at_verbose = echo && cat stderr;:],
- experr, [AT_DEFINE([AT_data_experr], [ experr])dnl
+ experr, [AT_CLEANUP_FILE([experr])dnl
$at_diff experr stderr || at_failed=:],
[], [$at_diff empty stderr || at_failed=:],
[echo $at_n "m4_patsubst([$4], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stderr || at_failed=:])
m4_case([$3],
ignore, [test $at_verbose = echo && cat stdout;:],
- expout, [AT_DEFINE([AT_data_expout], [ expout])dnl
+ expout, [AT_CLEANUP_FILES([expout])dnl
$at_diff expout stdout || at_failed=:],
[], [$at_diff empty stdout || at_failed=:],
[echo $at_n "m4_patsubst([$3], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stdout || at_failed=:])
# => active
m4_define([m4_append],
[m4_define([$1],
-ifdef([$1], [m4_defn([$1])])[$2])])
+ ifdef([$1], [m4_defn([$1])])[$2])])
# m4_list_append(MACRO-NAME, STRING)
# Same as `m4_append', but each element is separated by `, '.
m4_define([m4_list_append],
[m4_define([$1],
-ifdef([$1], [m4_defn([$1]), ])[$2])])
+ ifdef([$1], [m4_defn([$1]), ])[$2])])
# m4_foreach_quoted(VARIABLE, LIST, EXPRESSION)
# => active
m4_define([m4_append],
[m4_define([$1],
-ifdef([$1], [m4_defn([$1])])[$2])])
+ ifdef([$1], [m4_defn([$1])])[$2])])
# m4_list_append(MACRO-NAME, STRING)
# Same as `m4_append', but each element is separated by `, '.
m4_define([m4_list_append],
[m4_define([$1],
-ifdef([$1], [m4_defn([$1]), ])[$2])])
+ ifdef([$1], [m4_defn([$1]), ])[$2])])
# m4_foreach_quoted(VARIABLE, LIST, EXPRESSION)
# The group is testing what DESCRIPTION says.
AT_DEFINE([AT_SETUP],
[AT_DEFINE([AT_ordinal], m4_eval(AT_ordinal + 1))
-m4_pushdef([AT_data_files], )
-m4_pushdef([AT_data_expout], )
-m4_pushdef([AT_data_experr], )
+m4_pushdef([AT_data_files], [stdout stderr ])
m4_divert_pop()dnl
AT_ordinal )
dnl Here will be inserted the `rm' corresponding to AT_CLEANUP.
])
+# AT_CLEANUP_FILE_IFELSE(FILE, IF-REGISTERED, IF-NOT-REGISTERED)
+# --------------------------------------------------------------
+AT_DEFINE([AT_CLEANUP_FILE_IFELSE],
+[ifelse(m4_regexp(AT_data_files, m4_patsubst([ $1 ], [\([\[\]*.]\)], [\\\1])),
+ -1,
+ [$3], [$2])])
+
+
+# AT_CLEANUP_FILE(FILE)
+# ---------------------
+# Register FILE for AT_CLEANUP.
+AT_DEFINE([AT_CLEANUP_FILE],
+[AT_CLEANUP_FILE_IFELSE([$1], [],
+ [m4_append([AT_data_files], [$1 ])])])
+
+
+# AT_CLEANUP_FILES(FILES)
+# -----------------------
+# Declare a list of FILES to clean.
+AT_DEFINE([AT_CLEANUP_FILES],
+[m4_foreach([AT_File], m4_quote(m4_patsubst([$1], [ *], [,])),
+ [AT_CLEANUP_FILE(AT_File)])])
+
+
# AT_CLEANUP(FILES)
# -----------------
# Complete a group of related tests, recursively remove those FILES
# created within the test. There is no need to list stdout, stderr,
# nor files created with AT_DATA.
AT_DEFINE([AT_CLEANUP],
-[ $at_traceoff
+[AT_CLEANUP_FILES([$1])dnl
+ $at_traceoff
)
at_status=$?
at_test_count=`expr 1 + $at_test_count`
if $at_stop_on_error && test -n "$at_failed_list"; then :; else
- rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
+ rm -rf AT_data_files
fi
;;
m4_divert(1)[]dnl
- rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
+ rm -rf AT_data_files
m4_undivert(2)[]dnl
-m4_popdef([AT_data_experr])dnl
-m4_popdef([AT_data_expout])dnl
m4_popdef([AT_data_files])dnl
m4_divert_push([KILL])dnl
])# AT_CLEANUP
# This macro is not robust to active symbols in CONTENTS *on purpose*.
# If you don't want CONTENT to be evaluated, quote it twice.
AT_DEFINE([AT_DATA],
-[AT_DEFINE([AT_data_files], AT_data_files[ ]$1)
+[AT_CLEANUP_FILES([$1])dnl
cat >$1 <<'_ATEOF'
$2[]_ATEOF
])
dnl Restore stdout to fd1 and stderr to fd2.
exec 1>&5 2>&6
dnl If not verbose, neutralize the output of diff.
- test $at_verbose = echo && exec 1>/dev/null 2>/dev/null
+ test $at_verbose = : && exec 1>/dev/null 2>/dev/null
at_failed=false;
m4_case([$4],
ignore, [$at_verbose = echo && cat stderr;:],
- experr, [AT_DEFINE([AT_data_experr], [ experr])dnl
+ experr, [AT_CLEANUP_FILE([experr])dnl
$at_diff experr stderr || at_failed=:],
[], [$at_diff empty stderr || at_failed=:],
[echo $at_n "m4_patsubst([$4], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stderr || at_failed=:])
m4_case([$3],
ignore, [test $at_verbose = echo && cat stdout;:],
- expout, [AT_DEFINE([AT_data_expout], [ expout])dnl
+ expout, [AT_CLEANUP_FILES([expout])dnl
$at_diff expout stdout || at_failed=:],
[], [$at_diff empty stdout || at_failed=:],
[echo $at_n "m4_patsubst([$3], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stdout || at_failed=:])
## ---------------------------------------- ##
+# AT_CHECK_AUTOCONF
+# -----------------
+AT_DEFINE([AT_CHECK_AUTOCONF],
+[AT_CLEANUP_FILES(configure)dnl
+AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])])
+
+
+# AT_CHECK_AUTOHEADER
+# -------------------
+AT_DEFINE([AT_CHECK_AUTOHEADER],
+[AT_CLEANUP_FILES(config.hin)dnl
+AT_CHECK([autoheader --autoconf-dir .. -l $at_srcdir], 0, [], [])])
+
+
+# AT_CHECK_CONFIGURE
+# -------------------
+AT_DEFINE([AT_CHECK_CONFIGURE],
+[AT_CLEANUP_FILE_IFELSE([config.hin],
+ [AT_CLEANUP_FILE(config.h)])dnl
+AT_CLEANUP_FILES(config.log config.status config.cache)dnl
+AT_CHECK([top_srcdir=$top_srcdir ./configure], 0, ignore, [])
+test $at_verbose = echo && echo "--- config.log" && cat config.log])
+
+
# _AT_CHECK_AC_MACRO(AC-BODY, PRE-TESTS)
# --------------------------------------
# Create a minimalist configure.in running the macro named
# `config.guess' etc.).
AT_DEFINE([_AT_CHECK_AC_MACRO],
[dnl Produce the configure.in
+AT_CLEANUP_FILES(env-after state*)dnl
AT_DATA([configure.in],
[AC_INIT
AC_CONFIG_AUX_DIR($top_srcdir)
AC_OUTPUT
])
$2
-rm -f state*
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([autoheader --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([top_srcdir=$top_srcdir ./configure], 0, ignore, [])
-test $at_verbose = echo && echo "--- config.log" && cat config.log
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
dnl Some tests might exit prematurely when they find a problem, in
dnl which case `env-after' is probably missing. Don't check it then.
cp -f state-ls.before expout
AT_CHECK([cat state-ls.after], 0, expout)
fi
-rm -f state*
])# _AT_CHECK_AC_MACRO
_AT_CHECK_AC_MACRO([ifelse([$2],,[$1], [$2])])
$3
-AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+AT_CLEANUP()dnl
])# AT_CHECK_MACRO
[], [autoupdate: `configure.in' is updated
])])
-AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+AT_CLEANUP()dnl
])# AT_CHECK_UPDATE
AS_EXIT(0)
]])
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
AT_CHECK([./configure], 0)
AT_CLEANUP(configure)
AS_EXIT(0)
]])
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
AT_CHECK([./configure], 0)
AT_CLEANUP(configure)
AS_EXIT(0)
]])
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
AT_CHECK([./configure], 0)
AT_CLEANUP(configure 1 a)
esac
]])
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
AT_CHECK([./configure], 0)
AT_CLEANUP(configure)
AS_EXIT(0)
]])
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
-AT_CLEANUP(path config.log config.cache configure)
+AT_CLEANUP(path)
# ------------------------------ #
AS_EXIT(0)
]])
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
-AT_CLEANUP(path config.log config.cache configure)
+AT_CLEANUP(path)
#define HAVE_STDIO_H 1
])
-AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+AT_CLEANUP()dnl
# Non-strict preprocessors work if they produce no warnings.
#define HAVE_STDIO_H 1
])
-AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+AT_CLEANUP()dnl
[autoupdate: `configure.in' is updated
])
AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0)
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_CONFIGURE
AT_CHECK([cat src1], 0, [dst1
])
AT_CHECK([cat src2], 0, [dst2
AC_OUTPUT
]])
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
# Create a header
AT_CHECK([./configure what_to_test=header], 0, ignore)
AC_OUTPUT
]])
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
AT_CHECK([./configure], 1, ignore,
[[config.status: error: cannot find input file `nonexistent.in'
]])
AC_OUTPUT
]])
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
AT_CHECK([./configure one=one --enable-two=two --with-three=three |
sed -n -e 's/^result=//p'], 0,
]])
AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0)
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_CONFIGURE
AT_DATA(expout,
[[/* config.h. Generated automatically by configure. */
AC_OUTPUT
])
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([../autoheader --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
# Checking that AC_DEFINE worked properly.
AT_DATA(expout,