From: Eric Blake Date: Fri, 24 Apr 2009 14:46:59 +0000 (-0600) Subject: Make AT_CHECK_UNQUOTED more like AC_DEFINE_UNQUOTED. X-Git-Tag: v2.64~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5da9f24d5570dcdb6333a0678a1bdf2117c6e400;p=thirdparty%2Fautoconf.git Make AT_CHECK_UNQUOTED more like AC_DEFINE_UNQUOTED. * lib/autotest/general.m4 (AT_CHECK_NOESCAPE): Keep older, undocumented semantics, where unbalanced " cannot be used in the stdout/stderr argument. (AT_CHECK_UNQUOTED): Treat " in stdout/stderr as a literal, since the text is used in double-quoted context. * tests/autotest.at (unquoted output): New test. * doc/autoconf.texi (Writing Testsuites) : Mention which shell expansions are handled. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 1307b0c6e..a4c633276 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2009-04-24 Eric Blake + Make AT_CHECK_UNQUOTED more like AC_DEFINE_UNQUOTED. + * lib/autotest/general.m4 (AT_CHECK_NOESCAPE): Keep older, + undocumented semantics, where unbalanced " cannot be used in the + stdout/stderr argument. + (AT_CHECK_UNQUOTED): Treat " in stdout/stderr as a literal, since + the text is used in double-quoted context. + * tests/autotest.at (unquoted output): New test. + * doc/autoconf.texi (Writing Testsuites) : Mention which + shell expansions are handled. + Rename AT_CHECK_NOESCAPE to AT_CHECK_UNQUOTED. * lib/autotest/general.m4 (AT_CHECK_NOESCAPE): Deprecate, in favor of new spelling... diff --git a/doc/autoconf.texi b/doc/autoconf.texi index d1a77fa68..b013afa59 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -8760,7 +8760,8 @@ the last one wins. Like @code{AC_DEFINE}, but three shell expansions are performed---once---on @var{variable} and @var{value}: variable expansion (@samp{$}), command substitution (@samp{`}), and backslash escaping -(@samp{\}). Single and double quote characters in the value have no +(@samp{\}), as if in an unquoted here-doc. Single and double quote +characters in the value have no special meaning. Use this macro instead of @code{AC_DEFINE} when @var{variable} or @var{value} is a shell variable. Examples: @@ -22434,10 +22435,13 @@ parameter is treated as text that must exactly match the output given by @var{commands} on standard out and standard error (including an empty parameter for no output); any differences are captured in the testsuite log and the test is failed. The difference between @code{AT_CHECK} and -@code{AT_CHECK_UNQUOTED} is that only the latter performs shell -expansions on comparison text given in the @var{stdout} and @var{stderr} -arguments (however, there is no difference in the interpretation of -@var{commands}). +@code{AT_CHECK_UNQUOTED} is that only the latter performs shell variable +expansion (@samp{$}), command substitution (@samp{`}), and backslash +escaping (@samp{\}) on comparison text given in the @var{stdout} and +@var{stderr} arguments; if the text includes a trailing newline, this +would be the same as if it were specified via an unquoted +here-doc. (However, there is no difference in the interpretation +of @var{commands}). @table @samp @item ignore diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index f959a4189..a16224b89 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -1910,16 +1910,17 @@ _AT_DEFINE_SETUP([AT_CHECK], # Like AT_CHECK, but do not AS_ESCAPE shell metacharacters in the STDOUT # and STDERR arguments before running the comparison. _AT_DEFINE_SETUP([AT_CHECK_UNQUOTED], -[_AT_CHECK(m4_expand([$1]), [$2], m4_expand([$3]), - m4_expand([$4]), [$5], [$6])]) +[_AT_CHECK(m4_expand([$1]), [$2], AS_ESCAPE(m4_dquote(m4_expand([$3])), [""]), + AS_ESCAPE(m4_dquote(m4_expand([$4])), [""]), [$5], [$6])]) # AT_CHECK_NOESCAPE(COMMANDS, [STATUS = 0], STDOUT, STDERR, # [RUN-IF-FAIL], [RUN-IF-PASS]) # --------------------------------------------------------- # Obsolete spelling of AT_CHECK_UNQUOTED. m4_define([AT_CHECK_NOESCAPE], -[m4_warn([obsolete], [use AT_CHECK_UNQUOTED instead of $0])]dnl -[AT_CHECK_UNQUOTED($@)]) +[m4_warn([obsolete], [consider using AT_CHECK_UNQUOTED instead of $0])]dnl +[_AT_CHECK(m4_expand([$1]), [$2], m4_expand([$3]), + m4_expand([$4]), [$5], [$6])]) # _AT_DECIDE_TRACEABLE(COMMANDS) diff --git a/tests/autotest.at b/tests/autotest.at index 827808cd0..0fad78db6 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -287,6 +287,13 @@ AT_CHECK_AT_TEST([errexit], AT_CHECK([grep "1 .* inhibited subsequent" stderr], [], [ignore])], [--errexit]) +AT_CHECK_AT_TEST([unquoted output], + [m4_define([backtick], [`]) + a=a + AT_CHECK_UNQUOTED([echo 'a"b backtick`'], [], + [${a}"`echo 'b '`\`\backtick]m4_newline)], + [], [], [], [], [AT_KEYWORDS([AT@&t@_CHECK_UNQUOTED])]) + AT_CHECK_AT([Logging], [[AT_INIT([artificial test suite]) dnl intentionally write failing tests, to see what gets logged