]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
autotest: define AT_DATA_UNQUOTED
authorPaolo Bonzini <bonzini@gnu.org>
Fri, 7 Dec 2012 12:21:59 +0000 (13:21 +0100)
committerPaolo Bonzini <bonzini@gnu.org>
Fri, 7 Dec 2012 13:25:08 +0000 (14:25 +0100)
* 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 <bonzini@gnu.org>
NEWS
doc/autoconf.texi
lib/autotest/general.m4
tests/autotest.at

diff --git a/NEWS b/NEWS
index 6d5b5e94b278093c9b2cefed804f056b096b12b4..d0a38a31fab49bf13a978ed517833ec36dd9622c 100644 (file)
--- 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
index 5b556da87071b8738d5cf0e66891a710043ddfab..3f0dbb413d915bff62975741f50770b908d77f94 100644 (file)
@@ -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}, @
index 264a01a1252dcc5aabeaac66bf331c86e4234497..7be2e3bc23f73b3ec90dd0cb148d7b87cea995e5 100644 (file)
@@ -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
index b56d3f87a813b80da3f6e90e3a36da040d58677a..fe2e3bc46009c53c9ddfaaef47badb20e671b36d 100644 (file)
@@ -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.  ##
 ## ------------------ ##