From: Eric Blake Date: Mon, 13 Sep 2010 17:31:23 +0000 (-0600) Subject: autotest: work around zsh bug X-Git-Tag: v2.68~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cca574572a7ea89f31ca50df05e65c8d97ac905;p=thirdparty%2Fautoconf.git 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) : Document that this allows empty contents. * tests/autotest.at (AT_DATA): New test. Reported by Ralf Wildenhues. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 3fc150b5..fac4c15b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2010-09-13 Eric Blake + 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) : 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. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 30fcb19d..84715259 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -24193,7 +24193,8 @@ End the current test group. 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 cdc82b9a..78f1cc61 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 ab04dbe0..323006e0 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@&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. ## ## ------------------ ##