summaryrefslogtreecommitdiff
path: root/tests/torture.at
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-06-29 18:55:39 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-06-29 23:17:15 -0700
commitd330dd62730234b1f1eafaf3a946cbebf8c6503a (patch)
tree69103942361311629d9e768515ca735ef6bec8f4 /tests/torture.at
parent25014b40e0a9d194f87e6047c394e9a45b5ae938 (diff)
downloadautoconf-d330dd62730234b1f1eafaf3a946cbebf8c6503a.tar.gz
AC_REPLACE_FUNCS: invoke _AH_CHECK_FUNC and AC_LIBSOURCE unconditionally.
While investigating something else, I noticed that AC_REPLACE_FUNCS calls _AH_CHECK_FUNC and AC_LIBSOURCE in the success branch of an AC_CHECK_FUNC. This doesn’t work; both of those are marker macros that need to be expanded unconditionally at m4 time so that traces (placed by autoheader and automake, respectively) will fire. In order to fix this while keeping the code readable, I would up doing a major refactor. There are now four internal macros implementing AC_REPLACE_FUNCS. _AC_REPLACE_FUNC_U is called unconditionally for every shell word in the list passed to AC_REPLACE_FUNCS, and does _AH_CHECK_FUNC + AC_LIBSOURCE if it can, or issues a warning if it can’t. (It could make sense to make this a public function, if we think shell variables in the AC_REPLACE_FUNCS list need to be supported long-term. I dunno if there’s a use case that can’t be handled by AC_REPLACE_FUNCS inside a shell conditional just as well.) _AC_REPLACE_FUNC_L and _AC_REPLACE_FUNC_NL implement the actual test performed for each function to be replaced; the difference is that _L (for literal) can only be used on a function whose name is known at m4 expansion time, _NL (nonliteral) works regardless. _AC_REPLACE_FUNCS, which already existed, handles looping either at m4 time or shell time as appropriate. AC_REPLACE_FUNCS remains a thin wrapper that runs _AC_REPLACE_FUNCS(m4_flatten([$1])). The _bulk_ of the patch is changes to the testsuite so that it notices the original bug. Specifically, AT_CHECK_AUTOHEADER now takes an argument which is a whitespace-separated list of preprocessor macro names that ought to appear in the generated config.h.in. This can be set to ‘ignore’ to skip the test, and unfortunately that’s what the “trivial” per-macro tests have to do (AT_CHECK_MACRO and friends), so coverage is not ideal, but it’s better than what we had. Also, AT_CHECK_M4 now normalizes the backtrace lines that appear in the output of an AC_DIAGNOSE, e.g. configure.ac:6: warning: The macro `AC_LANG_SAVE' is obsolete. configure.ac:6: You should run autoupdate. ../../lib/autoconf/lang.m4:125: AC_LANG_SAVE is expanded from... configure.ac:6: the top level becomes configure.ac:6: warning: The macro `AC_LANG_SAVE' is obsolete. configure.ac:6: You should run autoupdate. lang.m4: AC_LANG_SAVE is expanded from... configure.ac:6: the top level This allows us to write tests for these diagnostics that don’t depend on the relationship between the source and build directories, and won’t break when unrelated patches change the line number of a macro definition. * lib/autoconf/functions.m4 (AC_REPLACE_FUNCS, _AC_REPLACE_FUNCS) (_AC_REPLACE_FUNC): Refactor into AC_REPLACE_FUNCS, _AC_REPLACE_FUNCS, _AC_REPLACE_FUNC_U, _AC_REPLACE_FUNC_L, _AC_REPLACE_FUNC_NL. Ensure that _AH_CHECK_FUNC and AC_LIBSOURCE are invoked unconditionally at m4 expansion time for each literal function name in the argument to AC_CHECK_FUNCS. Issue warnings about non-literal names. * tests/local.at (AT_CHECK_M4): Normalize backtrace lines from the output of AC_DIAGNOSE / m4_warn. (AT_CHECK_AUTOHEADER): Add arg EXPECTED-TMPLS giving a list of preprocessor macro names that should appear in the generated config.h.in. Use AT_CHECK_M4 to invoke autoheader. (_AT_CHECK_AC_MACRO, AT_CHECK_MACRO, AT_CHECK_AU_MACRO): Update uses of AT_CHECK_AUTOHEADER. * tests/fortran.at, tests/semantics.at, tests/tools.at * tests/torture.at: Update all uses of AT_CHECK_AUTOHEADER. * tests/semantics.at (AC_REPLACE_FUNCS test): Make somewhat more thorough, using new functionality of AT_CHECK_M4 and AT_CHECK_AUTOHEADER. Signed-off-by: Zack Weinberg <zackw@panix.com>
Diffstat (limited to 'tests/torture.at')
-rw-r--r--tests/torture.at13
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/torture.at b/tests/torture.at
index 5bc740ab..b50dfebc 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -716,7 +716,9 @@ AC_OUTPUT
]])# configure.ac
AT_CHECK_AUTOCONF
-AT_CHECK_AUTOHEADER
+AT_CHECK_AUTOHEADER([],
+ m4_for(AT_Count, 1, 100, 1, [ AT_DUMMY_VAR(AT_Count)]))
+
# Check both awk and the result of AC_PROG_AWK.
# Quote the first word in the for list for Solaris sh.
for awk_arg in "FOO=" AWK=awk; do
@@ -864,7 +866,7 @@ AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
]])
AT_CHECK_AUTOCONF
-AT_CHECK_AUTOHEADER
+AT_CHECK_AUTOHEADER([], [foo fooq])
AT_CHECK_CONFIGURE
AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
@%:@define fooq m4_for([n], 1, 100,, ....................)
@@ -946,7 +948,8 @@ AC_PROG_AWK
AC_CONFIG_FILES([Foo Zardoz])]])
AT_CHECK_AUTOCONF
-AT_CHECK_AUTOHEADER
+AT_CHECK_AUTOHEADER([],
+ [foo fooq bar barq unq1 unq2 unq2 unq3 unq4 unq5 unq6 unq7])
# Check both awk and the result of AC_PROG_AWK
# Quote the first word in the for list for Solaris sh.
for awk_arg in "FOO=" AWK=awk; do
@@ -1038,7 +1041,7 @@ AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
[[warning: AC_DEFINE: `one
two' is not a valid preprocessor define value
]])
-AT_CHECK_AUTOHEADER([], [], [], [stderr])
+AT_CHECK_AUTOHEADER([], [foo], [], [], [stderr])
AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
[[warning: AC_DEFINE: `one
two' is not a valid preprocessor define value
@@ -1055,7 +1058,7 @@ AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
[[warning: AC_DEFINE_UNQUOTED: `one
two' is not a valid preprocessor define value
]])
-AT_CHECK_AUTOHEADER([], [], [], [stderr])
+AT_CHECK_AUTOHEADER([], [foo], [], [], [stderr])
AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
[[warning: AC_DEFINE_UNQUOTED: `one
two' is not a valid preprocessor define value