summaryrefslogtreecommitdiff
path: root/tests/base.at
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-08-14 13:16:58 -0400
committerZack Weinberg <zackw@panix.com>2020-08-18 08:24:05 -0400
commitaba75f6d4a9c875a9d5d90a07c6b3678db66a4bf (patch)
treebd22316093ce106881b5d9d5574dbdbc65d72191 /tests/base.at
parent6a0c0239449a98181c5dd7e505cddbc0840471a4 (diff)
downloadautoconf-aba75f6d4a9c875a9d5d90a07c6b3678db66a4bf.tar.gz
Warn if AC_INIT or AC_OUTPUT are missing from configure.ac (#107986)
It is almost always incorrect for a configure script to omit either AC_INIT or AC_OUTPUT. Issue warnings in the ‘syntax’ category for this. The implementation is, unfortunately, a bit of a kludge. To check for the _absence_ of a macro invocation, we can use m4_provide_if inside a m4_wrap hook. However, if we activate the m4_wrap hook directly from general.m4, we get spurious warnings at freeze time. We also get warnings whenever a script that’s missing AC_INIT and/or AC_OUTPUT is *traced*, which means we get double warnings from autoconf, and autoheader and aclocal complain about it too, which seems unnecessary. A clean way to deal with this would be to make the hook look for a special macro that’s defined only when autoconf (the program) is invoked without any --trace arguments. Unfortunately, autom4te doesn’t pass --define down to M4, and changing that would involve coordinating with Automake (the project), so instead I’ve gone for the kludge: a new file lib/autoconf/trailer.m4 that calls m4_wrap. This file is *not* included in autoconf.m4f, but it’s installed, and it’s added to the m4 invocation by autoconf (the program) only when not tracing. (It still uses m4_wrap, because we pass it to m4 *before* configure.ac, because otherwise we get nonsense locations for any *other* diagnostics coming out of this autoconf invocation. I don’t know why.) The additional checks in autoreconf are intended to make sure that if autoreconf skips a directory entirely, you get told why. Lots of tests in the testsuite didn’t bother with AC_OUTPUT, and somewhat fewer didn’t bother with AC_INIT; where possible I just added them. Suggested by David A. Wheeler, who submitted a patch, but I didn’t wind up using any of his code. (His implementation used an extra tracing pass, only checked for a missing AC_INIT, and invented a new command-line option to turn off this specific warning. I thought this was tidier overall, despite the kludge.) * lib/autoconf/general.m4 (_AC_FINALIZE): New macro: code to be run when generating configure, after the entire configure.ac is processed. Currently only checks that AC_INIT and AC_OUTPUT were called at some point, issuing syntax-category warnings if not. (AC_INIT, AC_OUTPUT): m4_provide self. * lib/autoconf/trailer.m4: New file that just calls m4_wrap([_AC_FINALIZE]). * lib/local.mk: Install new file. * bin/autoconf.as: Add trailer.m4 to the final invocation of autom4te, but only when not tracing. * bin/autoreconf.in (autoreconf_current_directory): Distinguish in diagnostics between “directory skipped because it doesn’t have a configure.ac or configure.in” (e.g. Cygnus configure) and “directory has a configure.ac but it doesn’t appear to be autoconf input.” * tests/*.at: Fix all tests affected by the new warnings.
Diffstat (limited to 'tests/base.at')
-rw-r--r--tests/base.at33
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/base.at b/tests/base.at
index 98125173..4042a8aa 100644
--- a/tests/base.at
+++ b/tests/base.at
@@ -57,7 +57,10 @@ test -z "$test1" &&
AS_EXIT(0)
]])
-AT_CHECK_AUTOCONF
+AT_CHECK_AUTOCONF([], [0], [],
+[[trailer.m4: warning: AC_INIT was never used
+trailer.m4: warning: AC_OUTPUT was never used
+]])
AT_CHECK_CONFIGURE
AT_CLEANUP
@@ -117,7 +120,10 @@ case $multi_test:$single_test in
esac
]])
-AT_CHECK_AUTOCONF([], 0, [])
+AT_CHECK_AUTOCONF([], 0, [],
+[[trailer.m4: warning: AC_INIT was never used
+trailer.m4: warning: AC_OUTPUT was never used
+]])
AT_CHECK_CONFIGURE
@@ -160,7 +166,10 @@ case $multi_test:$single_test in
esac
]])
-AT_CHECK_AUTOCONF([], 0, [])
+AT_CHECK_AUTOCONF([], 0, [],
+[[trailer.m4: warning: AC_INIT was never used
+trailer.m4: warning: AC_OUTPUT was never used
+]])
AT_CHECK_CONFIGURE
AT_CLEANUP
@@ -192,7 +201,10 @@ case $inner_test in
esac
]])
-AT_CHECK_AUTOCONF
+AT_CHECK_AUTOCONF([], 0, [],
+[[trailer.m4: warning: AC_INIT was never used
+trailer.m4: warning: AC_OUTPUT was never used
+]])
AT_CHECK_CONFIGURE
AT_CLEANUP
@@ -208,6 +220,7 @@ AT_SETUP([AC_INIT])
AT_DATA([configure.ac],
[[AC_INIT([GNU fu], [1.0], [bug-fu@gnu.org])
+AC_OUTPUT
]])
AT_CHECK_AUTOCONF
@@ -354,6 +367,7 @@ words that may be matched by scanners for legal things,
causing extra work for distributors.
Multi-line values should be supported.
]])
+AC_OUTPUT
]])
AT_CHECK_AUTOCONF
@@ -403,8 +417,7 @@ if ${my_cv_variable+false} :; then
AC_MSG_ERROR([AC@&@&t@t@_CACHE_VAL did not ensure that the cache variable was set])
fi
-# AC_CACHE_SAVE should be enough here, no need for AC_OUTPUT.
-AC_CACHE_SAVE
+AC_OUTPUT
]])
AT_CHECK_AUTOCONF([], [], [], [stderr])
@@ -603,6 +616,7 @@ AC_COMPUTE_INT([invalid_expression],
[invalid_expression=failed])
test "$invalid_expression" = failed ||
AC_MSG_ERROR([**0** evaluated to $invalid_expression instead of failing])
+AC_OUTPUT
]])
AT_CHECK_AUTOCONF
@@ -633,6 +647,8 @@ if AC_TRY_COMMAND([(echo "The Cat in the Hat";
grep \^The\ Hat\ in\ the\ Cat\$ >/dev/null]); then
AC_MSG_ERROR([saw the Hat in the Cat])
fi
+
+AC_OUTPUT
]])
AT_CHECK_AUTOCONF
@@ -650,9 +666,10 @@ AT_SETUP([Input/Output])
AT_DATA([configure.ac],
[[AC_INIT
cat <&AS@&t@_ORIGINAL_STDIN_FD >&AS@&t@_MESSAGE_FD
+AC_OUTPUT
]])
AT_CHECK_AUTOCONF
-AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options | grep -v 'configure: loading site script '],, [Hello
+AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options | grep -v '^configure: '],, [Hello
])
AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options --silent])
@@ -668,6 +685,7 @@ AT_SETUP([configure arguments])
AT_DATA([configure.ac],
[[AC_INIT
echo "$@"
+AC_OUTPUT
]])
AT_CHECK_AUTOCONF
@@ -706,6 +724,7 @@ AC_ARG_ENABLE([c++],
echo "use_foo: $use_foo"
echo "with_c++: $with_c__, $choice_with"
echo "enable_c++: $enable_c__, $choice_enable"
+AC_OUTPUT
]])
AT_CHECK_AUTOCONF