From: Paolo Bonzini Date: Fri, 7 Dec 2012 12:21:59 +0000 (+0100) Subject: autotest: define AT_DATA_UNQUOTED X-Git-Tag: v2.69b~184 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42b4918d161806fc56d15007c3129b50c1f94d12;p=thirdparty%2Fautoconf.git autotest: define AT_DATA_UNQUOTED * lib/autotest/general.m4 (AT_DATA_UNQUOTED): New macro, paralleling AT_DATA but not quoting the contents. * doc/autoconf.texi (Writing Testsuites): Document it. * tests/autotest.at (AT_DATA_UNQUOTED): Test it. Signed-off-by: Paolo Bonzini --- diff --git a/NEWS b/NEWS index 6d5b5e94..d0a38a31 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,11 @@ GNU Autoconf NEWS - User visible changes. code on that platform. Solaris 2.4 has not been supported since 2003 and nowadays it's better to omit that old trick. +- Autotest provides a new macro AT_DATA_UNQUOTED, similar to AT_DATA + but processing variable substitutions, command substitutions and + backslashes in the contents argument. + + * Noteworthy changes in release 2.69 (2012-04-24) [stable] ** Autoconf now requires perl 5.6 or better (but generated configure diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 5b556da8..3f0dbb41 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -25128,6 +25128,7 @@ End the current test group. @sp 1 @defmac AT_DATA (@var{file}, @var{contents}) +@defmacx AT_DATA_UNQUOTED (@var{file}, @var{contents}) @atindex{DATA} Initialize an input data @var{file} with given @var{contents}. Of course, the @var{contents} have to be properly quoted between square @@ -25135,6 +25136,11 @@ brackets to protect against included commas or spurious M4 expansion. @var{contents} must be empty or end with a newline. @var{file} must be a single shell word that expands into a single file name. + +The difference between @code{AT_DATA} and @code{AT_DATA_UNQUOTED} is +that only the latter performs shell variable expansion (@samp{$}), +command substitution (@samp{`}), and backslash escaping (@samp{\}) +on @var{contents}. @end defmac @defmac AT_CHECK (@var{commands}, @dvar{status, 0}, @ovar{stdout}, @ diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index 264a01a1..7be2e3bc 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -1944,6 +1944,22 @@ at_banner_text_[]AT_banner_ordinal="AS_ESCAPE([$1])"])dnl ])# AT_BANNER +# AT_DATA_UNQUOTED(FILE, CONTENTS) +# ----------------------- +# Initialize an input data FILE with given CONTENTS, which should be +# empty or end with a newline. +# This macro is not robust to active symbols in CONTENTS *on purpose*. +# If you don't want CONTENTS to be evaluated, quote it twice. +# In addition, it does not quote shell variables. For example, it +# can be used to generate data files containing a carriage return. +_AT_DEFINE_SETUP([AT_DATA_UNQUOTED], +[m4_if([$2], [], [: >$1], + [$2], [[]], [: >$1], +[cat >$1 <<_ATEOF +$2[]_ATEOF +])]) + + # AT_DATA(FILE, CONTENTS) # ----------------------- # Initialize an input data FILE with given CONTENTS, which should be diff --git a/tests/autotest.at b/tests/autotest.at index b56d3f87..fe2e3bc4 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -177,6 +177,25 @@ AT_CHECK([cmp file2 file3]) ]) +## ------------------ ## +## AT_DATA_UNQUOTED. ## +## ------------------ ## + +AT_CHECK_AT_TEST([AT@&t@_DATA_UNQUOTED], [ +AT_CHECK([test -f file1], [1]) +AT_DATA([file1]) +AT_CHECK([test -f file1 && test ! -s file1]) +AT_CHECK([echo hi > file1]) +AT_DATA([file1], [[]]) +AT_CHECK([test -f file1 && test ! -s file1]) +file=file2 +AT_DATA_UNQUOTED([$file], [[$file +]]) +AT_CHECK([echo file2 > file3]) +AT_CHECK([cmp file2 file3]) +]) + + ## ------------------ ## ## Empty test suite. ## ## ------------------ ##