2010-09-13 Eric Blake <eblake@redhat.com>
+ autotest: work around zsh bug
+ * lib/autotest/general.m4 (AT_DATA): Special case an empty data
+ file, since zsh botches empty here-docs.
+ * doc/autoconf.texi (Writing Testsuites) <AT_DATA>: Document that
+ this allows empty contents.
+ * tests/autotest.at (AT_DATA): New test.
+ Reported by Ralf Wildenhues.
+
docs: mention gnulib portability docs
* doc/autoconf.texi (Function Portability, Header Portability):
Add external links to gnulib.
Initialize an input data @var{file} with given @var{contents}. Of
course, the @var{contents} have to be properly quoted between square
brackets to protect against included commas or spurious M4
-expansion. The contents must end with an end of line. @var{file} must
+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.
@end defmac
# AT_DATA(FILE, CONTENTS)
# -----------------------
-# Initialize an input data FILE with given CONTENTS, which should end with
-# an end of line.
+# 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.
_AT_DEFINE_SETUP([AT_DATA],
+[m4_if([$2], [], [: >$1],
+ [$2], [[]], [: >$1],
[cat >$1 <<'_ATEOF'
$2[]_ATEOF
-])
+])])
# AT_CHECK(COMMANDS, [STATUS = 0], STDOUT, STDERR,
[--version])
+## --------- ##
+## AT_DATA. ##
+## --------- ##
+
+AT_CHECK_AT_TEST([AT@&t@_DATA], [
+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([$file], [[$file
+]])
+AT_CHECK([echo '$file' > file3])
+AT_CHECK([cmp file2 file3])
+])
+
+
## ------------------ ##
## Empty test suite. ##
## ------------------ ##