* 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 <[email protected]> --- NEWS | 5 +++++ doc/autoconf.texi | 6 ++++++ lib/autotest/general.m4 | 16 ++++++++++++++++ tests/autotest.at | 19 +++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/NEWS b/NEWS index 6d5b5e9..d0a38a3 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 075eafe..b0526da 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -25131,6 +25131,7 @@ Writing Testsuites @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 @@ -25138,6 +25139,11 @@ Writing Testsuites 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 264a01a..7be2e3b 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 b56d3f8..fe2e3bc 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -178,6 +178,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. ## ## ------------------ ## -- 1.8.0.1
