autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] autotest: work around zsh bug


From: Eric Blake
Subject: [PATCH] autotest: work around zsh bug
Date: Mon, 13 Sep 2010 11:38:03 -0600

* 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
empty contents is allowed.
* tests/autotest.at (AT_DATA): New test.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <address@hidden>
---

Independent of the doc patch about the zsh bug, it turned out
to be pretty easy to work around it in AT_DATA.

By testing the tests/ change independently from the rest of the
patch, I've confirmed that bash passes both before and after, while
zsh fails before but passes after the rest of the patch.

This does not protect against:
AT_DATA([file], [macro_that_expands_to_nothing])
but I suspect that is enough of a corner case to not worry about
unless we get a specific report of someone needing it.

 ChangeLog               |    8 ++++++++
 doc/autoconf.texi       |    2 +-
 lib/autotest/general.m4 |    8 +++++---
 tests/autotest.at       |   19 +++++++++++++++++++
 4 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5b68441..951d971 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-09-13  Eric Blake  <address@hidden>

+       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
+       empty contents is allowed.
+       * 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.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 62a17f7..fcce699 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -24161,7 +24161,7 @@ Writing Testsuites
 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

diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index cdc82b9..9429089 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -1947,14 +1947,16 @@ 
at_banner_text_[]AT_banner_ordinal="AS_ESCAPE([$1])"])dnl

 # 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,
diff --git a/tests/autotest.at b/tests/autotest.at
index fc636e9..4becdd5 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -159,6 +159,25 @@ AT_CHECK([sed 50q micro-suite | grep 'This is just a test 
notice'],
 [--version])


+## --------- ##
+## AT_DATA.  ##
+## --------- ##
+
+AT_CHECK_AT_TEST([AT@&address@hidden, [
+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.  ##
 ## ------------------ ##
-- 
1.7.2.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]