From 1bb104167ed88a355a1c66e3e86cd49d9128cc4b Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 15 Aug 2012 22:17:49 -0600 Subject: [PATCH] AC_SUBST: document and test previous patch Test that: invalid variable names are detected, that the variable name does not get macro expanded, that assignment to the variable works whether as part of AC_SUBST or independently, that the last assignment wins. * doc/autoconf.texi (Setting Output Variables) : Mention that variable does not overlap with macros. * tests/base.at (AC_SUBST): New test. Signed-off-by: Eric Blake --- doc/autoconf.texi | 3 ++- tests/base.at | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/doc/autoconf.texi b/doc/autoconf.texi index c4ebe113..b3f7a238 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -9876,7 +9876,8 @@ output file may contain @code{|#_!!_#|}.) If @var{value} is given, in addition assign it to @var{variable}. The string @var{variable} is passed to @code{m4_pattern_allow} -(@pxref{Forbidden Patterns}). +(@pxref{Forbidden Patterns}). @var{variable} is not further expanded, +even if there is another macro by the same name. @end defmac @defmac AC_SUBST_FILE (@var{variable}) diff --git a/tests/base.at b/tests/base.at index 79794133..d8550df7 100644 --- a/tests/base.at +++ b/tests/base.at @@ -708,3 +708,62 @@ libdir=${exec_prefix}/lib ]]) AT_CLEANUP + +## ---------- ## +## AC_SUBST. ## +## ---------- ## + +AT_SETUP([AC_SUBST]) +AT_KEYWORDS([AS@&t@_IDENTIFIER_IF]) + +# Check that a valid variable name is used. +AT_DATA([configure.ac], +[[AC_INIT([test], [1]) +AC_SUBST([1], [bar]) +AC_OUTPUT +]]) +AT_CHECK_AUTOCONF([], [1], [], [stderr]) +AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore]) + +AT_DATA([configure.ac], +[[AC_INIT([test], [1]) +AC_SUBST([], [bar]) +AC_OUTPUT +]]) +AT_CHECK_AUTOCONF([], [1], [], [stderr]) +AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore]) + +AT_DATA([configure.ac], +[[AC_INIT([test], [1]) +AC_SUBST([*], [bar]) +AC_OUTPUT +]]) +AT_CHECK_AUTOCONF([], [1], [], [stderr]) +AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore]) + +# Make sure AC_SUBST handles variables as expected. +AT_DATA([file.in], +[[@FOO@ +@BAR@ +FOO +]]) +AT_DATA([configure.ac], +[[AC_INIT([test], [0]) +m4_define([FOO], [baz]) +AC_SUBST([FOO], [bar]) +BAR=one +AC_SUBST([B@&t@AR]) +BAR=two +AC_CONFIG_FILES([file]) +AC_OUTPUT +]]) + +AT_CHECK_AUTOCONF([], [], [], [stderr]) +AT_CHECK_CONFIGURE +AT_CHECK([cat file], [], +[[bar +two +FOO +]]) + +AT_CLEANUP -- 2.47.2