autoconf-patches
[Top][All Lists]
Advanced

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

Re: testsuite -C dir


From: Eric Blake-1
Subject: Re: testsuite -C dir
Date: Tue, 29 Jan 2008 16:11:23 -0800 (PST)

> Libtool mainline uses Autotest and a section
> 
>   m4_divert_push([PREPARE_TESTS])
>   ...
>   m4_divert_pop([PREPARE_TESTS])

and it did so PRIOR to calling AT_INIT.  If you merely swap
that around, and call AT_INIT before m4_divert_push, then
libtool would work regardless of autoconf version.

But, since I'm feeling nice, I'm committing the following,
which should let libtool work once again without
reordering its current usage.

> This fails with Autoconf mainline now (after the recent patches) because
> $LIBTOOL is not set yet; it is set in the call from the Makefile with
>   ./testsuite LIBTOOL=...

That seems rather brittle.  It means that you can't invoke
libtool's testsuite without supplying a definition for LIBTOOL.
But at least that's not autoconf's problem.

> I understand that Libtool uses a diversion that has not been documented
> in the manual; but IIRC then Autotest's diversion were intended to be
> usable by the user,

...to some degree.  Actually, I almost documented
the PARSE_ARGS and HELP_OTHER, then realized that
the better interface to document would be AT_ARG_OPTION
(in general, I like to discourage arbitrary use of the diversions,
and encourage using wrapper macros that write to the
correct diversion, so that we can change diversions under
the hood and still make the wrapper macros work correctly).
But I'm not sure that AT_ARG_OPTION is polished enough
to document yet, so I left that undocumented for now.
Almost all of the other diversions documented in the
leading comments of autotest/general.m4 have readily
identifiable and documented macros to generate text
for those diversions.

> and anyway I dislike breaking interfaces
> gratuitously.

This is the winning argument that made me be nice.
PREPARE_TESTS is now a documented diversion, so
libtool's usage is now kosher.  Hmm, I guess this patch
doesn't quite prove that we won't regress, though.
I guess I'll have to write another patch tomorrow.

From: Eric Blake <address@hidden>
Date: Tue, 29 Jan 2008 16:56:36 -0700
Subject: [PATCH] Fix more autotest regressions.

* lib/autotest/general.m4 (AT_LINE): Fix regression from
2007-10-04 when file name is `dnl'.
(AT_INIT) <PREPARE_TESTS>: Move command-line assignments...
<TESTS_BEGIN>: ...to this new diversion, to fix regression from
yesterday in libtool's testsuite.
(_AT_ARG_OPTION): Detect write failure.
* doc/autoconf.texi (Diversion support): Document PREPARE_TESTS to
make libtool's use kosher.  Document m4_init.
(Programming in M4sh): Document AS_INIT.
(Writing Testsuites): Document limitation of AT_DATA file name.
* tests/autotest.at (unusual file names): New test.
(Banners, Keywords and ranges): Use correct shell.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   14 +++++++++++
 doc/autoconf.texi       |   42 +++++++++++++++++++++++++++++++---
 lib/autotest/general.m4 |   24 ++++++++++++-------
 tests/autotest.at       |   56
++++++++++++++++++++++++++++++++++++++--------
 4 files changed, 113 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5af0f7d..1d547ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2008-01-29  Eric Blake  <address@hidden>
 
+       Fix more autotest regressions.
+       * lib/autotest/general.m4 (AT_LINE): Fix regression from
+       2007-10-04 when file name is `dnl'.
+       (AT_INIT) <PREPARE_TESTS>: Move command-line assignments...
+       <TESTS_BEGIN>: ...to this new diversion, to fix regression from
+       yesterday in libtool's testsuite.
+       (_AT_ARG_OPTION): Detect write failure.
+       * doc/autoconf.texi (Diversion support): Document PREPARE_TESTS to
+       make libtool's use kosher.  Document m4_init.
+       (Programming in M4sh): Document AS_INIT.
+       (Writing Testsuites): Document limitation of AT_DATA file name.
+       * tests/autotest.at (unusual file names): New test.
+       (Banners, Keywords and ranges): Use correct shell.
+
        More corner cases in testsuite VAR=VALUE handling.
        * lib/autotest/general.m4 (AT_INIT) <PREPARE_TESTS): Fix quoting
        bug.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 9c5b192..e40a7ed 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10436,7 +10436,11 @@ To make diversion management easier, M4sugar uses
the concept of named
 diversions.  Rather than using diversion numbers directly, it is nicer
 to associate a name with each diversion; the diversion number associated
 with a particular diversion name is an implementation detail, so you
-should only use diversion names.
+should only use diversion names.  In general, you should not output text
+to a named diversion until after calling the appropriate initialization
+routine for your language (@code{m4_init}, @code{AS_INIT},
address@hidden, @dots{}), although there are some exceptions documented
+below.
 
 M4sugar defines two named diversions.
 @table @code
@@ -10469,8 +10473,23 @@ This diversion contains the body of the shell code,
and is the default
 diversion once M4sh is initialized.
 @end table
 
-For now, the named diversions of Autoconf, Autoheader, and Autotest are
-not documented.
+Autotest inherits diversions from M4sh, and changes the default
+diversion from @code{BODY} back to @code{KILL}.  It also adds several
+more named diversions, with the following subset designed for developer
+use.
address@hidden @code
address@hidden PREPARE_TESTS
+This diversion contains initialization sequences which are executed
+after @file{atconfig} and @file{atlocal}, and after all command line
+arguments have been parsed, but prior to running any tests.  It can be
+used to set up state that is required across all tests.  This diversion
+will work even before @code{AT_INIT}.
address@hidden table
+
+For now, the named diversions of Autoconf and Autoheader, and the
+remaining diversions of Autotest, are not documented.  In other words,
+intentionally outputting text into an undocumented diversion is subject
+to breakage in a future release of Autoconf.
 
 @defmac m4_divert_once (@var{diversion}, @ovar{content})
 @msindex{divert_once}
@@ -10505,6 +10524,12 @@ m4_divert_pop(address@hidden)dnl
 @end example
 @end defmac
 
address@hidden m4_init
address@hidden
+Initialize the M4sugar environment, setting up the default named
+diversion to be @code{KILL}.
address@hidden defmac
+
 @node Conditional constructs
 @subsection Conditional constructs
 
@@ -11391,6 +11416,14 @@ ensures any required macros of @code{HANDLE_FOO}
 are expanded before the first test.
 @end defmac
 
address@hidden AS_INIT
address@hidden
+Initialize the M4sh environment.  This macro calls @code{m4_init}, then
+outputs the @code{#! /bin/sh} line, a notice about where the output was
+generated from, and code to sanitize the environment for the rest of the
+script.  Finally, it changes the current diversion to @code{BODY}.
address@hidden defmac
+
 @defmac AS_MKDIR_P (@var{file-name})
 @asindex{MKDIR_P}
 Make the directory @var{file-name}, including intervening directories
@@ -20160,7 +20193,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 ought to end with an end of line.
+expansion.  The contents must end with an end of line.  @var{file} must
+be a single shell word that expands into a single file name.
 @end defmac
 
 @defmac AT_CHECK (@var{commands}, @dvar{status, 0}, @dvar{stdout, }, @
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 7c45a7a..5f60f86 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -97,11 +97,13 @@
 #
 #  - BANNERS
 #    Output shell initialization for the associative array of banner text.
-#  - PREPARE_TESTS
+#  - TESTS_BEGIN
 #    Like DEFAULTS but run after argument processing for purposes of
 #    optimization.  Do anything else that needs to be done to prepare for
 #    tests.  Sets up verbose and log file descriptors.  Sets and logs PATH.
-#    Declares functions shared among the tests.
+#  - PREPARE_TESTS
+#    Declares functions shared among the tests.  Perform any user
+#    initialization to be shared among all tests.
 #  - TESTS
 #    The core of the test suite.
 #
@@ -127,8 +129,9 @@ m4_define([_m4_divert(VERSION)],            350)
 m4_define([_m4_divert(VERSION_NOTICES)],    351)
 m4_define([_m4_divert(VERSION_END)],        352)
 m4_define([_m4_divert(BANNERS)],            400)
-m4_define([_m4_divert(PREPARE_TESTS)],      401)
-m4_define([_m4_divert(TESTS)],              402)
+m4_define([_m4_divert(TESTS_BEGIN)],        401)
+m4_define([_m4_divert(PREPARE_TESTS)],      402)
+m4_define([_m4_divert(TESTS)],              403)
 m4_define([_m4_divert(TEST_SCRIPT)],        450)
 m4_define([_m4_divert(TEST_GROUPS)],        500)
 
@@ -160,8 +163,7 @@ m4_define([AT_LINE],
 [m4_if(m4_defn([_AT_LINE_file]), __file__, [],
        [m4_do([m4_define([_AT_LINE_file], __file__)],
              [m4_define([_AT_LINE_base],
-                        m4_bpatsubst(__file__, [^.*/\([^/]*\)$],
-                                     [[\1]]))])])dnl
+                        m4_bregexp(/__file__, [/\([^/]*\)$], [[\1]]))])])dnl
 m4_defn([_AT_LINE_base]):__line__])
 
 
@@ -697,7 +699,7 @@ _ACEOF
   exit $at_write_fail
 fi
 m4_divert_pop([VERSION_END])dnl
-m4_divert_push([PREPARE_TESTS])dnl
+m4_divert_push([TESTS_BEGIN])dnl
 
 # Take any -C into account.
 if $at_change_dir ; then
@@ -852,7 +854,11 @@ AS_BOX(m4_defn([AT_TESTSUITE_NAME])[.])
     sed 's/^/| /' $at_file
     echo
   done
+} >&AS_MESSAGE_LOG_FD
 
+m4_divert_pop([TESTS_BEGIN])dnl
+m4_divert_push([PREPARE_TESTS])dnl
+{
   AS_BOX([Tested programs.])
   echo
 } >&AS_MESSAGE_LOG_FD
@@ -1252,13 +1258,13 @@ m4_divert_push([KILL])
 # Internal implementation of AT_ARG_OPTION & AT_ARG_OPTION_ARG
 m4_defun([_AT_ARG_OPTION],
 [m4_divert_once([HELP_OTHER],
-[cat <<_ATEOF
+[cat <<_ATEOF || at_write_fail=1
 
 Other options:
 _ATEOF
 ])dnl m4_divert_once HELP_OTHER
 m4_divert_text([HELP_OTHER],
-[cat <<_ATEOF
+[cat <<_ATEOF || at_write_fail=1
 $2
 _ATEOF])dnl
 dnl Turn our options into our desired strings
diff --git a/tests/autotest.at b/tests/autotest.at
index 4e016d7..d9486d0 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -495,7 +495,7 @@ AT_CHECK_AUTOM4TE([--language=autotest -o b b.at])
 
 # AT_CHECK_BANNERS(TESTSUITE-OPTIONS, PATTERN1, COUNT1, PATTERN2, COUNT2)
 m4_define([AT_CHECK_BANNERS],
-[AT_CHECK([./b $1], [], [stdout])
+[AT_CHECK([$CONFIG_SHELL ./b $1], [], [stdout])
 AT_CHECK_EGREP([$2], m4_if([$3], [0], [1], [0]), [$3])
 AT_CHECK_EGREP([$4], m4_if([$5], [0], [1], [0]), [$5])
 ])
@@ -552,11 +552,11 @@ AT_CHECK_AUTOM4TE([--language=autotest -o k k.at])
 dnl check that AT_KEYWORDS does not duplicate words
 AT_CHECK([grep 'key1.*key1' k], [1])
 dnl check that -k requires an argument
-AT_CHECK([./k -k], [1], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k -k], [1], [], [ignore])
 
 # AT_CHECK_KEYS(TESTSUITE-OPTIONS, PATTERN1, COUNT1, PATTERN2, COUNT2)
 m4_define([AT_CHECK_KEYS],
-[AT_CHECK([./k $1], 0, [stdout])
+[AT_CHECK([$CONFIG_SHELL ./k $1], 0, [stdout])
 AT_CHECK_EGREP([$2], 0, [$3])
 AT_CHECK_EGREP([$4], 1, [$5])
 ])
@@ -593,13 +593,13 @@ AT_CHECK_KEYS([-3], [none|first|second], [3], [both],
[0])
 AT_CHECK_KEYS([4-], [both], [1], [none|first|second], [0])
 AT_CHECK_KEYS([-k second 4-], [second|both], [2], [none|first], [0])
 
-AT_CHECK([./k 0], [1], [ignore], [ignore])
-AT_CHECK([./k 0-], [1], [ignore], [ignore])
-AT_CHECK([./k -0], [1], [ignore], [ignore])
-AT_CHECK([./k 5], [1], [ignore], [ignore])
-AT_CHECK([./k 5-], [1], [ignore], [ignore])
-AT_CHECK([./k 1-5], [1], [ignore], [ignore])
-AT_CHECK([./k -k nonexistent], [0], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 0], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 0-], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k -0], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 5], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 5-], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 1-5], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k -k nonexistent], [0], [ignore])
 
 AT_CHECK_KEYS([--list -k nonexistent], [KEYWORDS], [1],
[first|second|both], [0])
 AT_CHECK_KEYS([--list 1], [none], [1], [first|second|both], [0])
@@ -712,3 +712,39 @@ AT_CHECK([top_srcdir=$wd ./suite], [0], [ignore])
 AT_CHECK([top_srcdir=$wd ./suite -d], [0], [ignore])
 AT_CHECK([cd suite.dir/1 && ./run top_srcdir="$wd"], [0], [ignore])
 AT_CLEANUP
+
+
+## ------------------ ##
+## unusual file names ##
+## ------------------ ##
+
+AT_SETUP([unusual file names])
+AT_KEYWORDS([autotest])
+
+AT_DATA_M4SUGAR([d@&address@hidden,
+[[AT_SETUP([test one])
+m4_pattern_allow([^dnl$])
+AT_CHECK([test "]m4_dquote(AT_LINE)[" = dn[]l.at:3])
+AT_CLEANUP
+]])
+
+mkdir sub
+AT_DATA_M4SUGAR([sub/"two  spaces".at],
+[[AT_SETUP([test two])
+AT_CHECK([test "]m4_dquote(AT_LINE)[" = "two  spaces.at:2"])
+AT_CLEANUP
+]])
+
+AT_DATA([suite.at],
+[[m4_define([AT_PACKAGE_NAME],    [GNU Nonsense])
+m4_define([AT_PACKAGE_TARNAME],   [nonsense])
+m4_define([AT_PACKAGE_VERSION],   [1.0])
+m4_define([AT_PACKAGE_STRING],    [GNU Nonsense 1.0])
+m4_define([AT_PACKAGE_BUGREPORT], address@hidden)
+AT_INIT([suite to check included file names])
+m4@&address@hidden([d][nl.at])
+m4@&address@hidden([sub/two  spaces.at])
+]])
+AT_CHECK_AUTOM4TE([--language=autotest -o suite suite.at])
+AT_CHECK([$CONFIG_SHELL ./suite], [0], [ignore])
+AT_CLEANUP
-- 
1.5.3.8


-- 
View this message in context: 
http://www.nabble.com/testsuite--C-dir-tp15115560p15172724.html
Sent from the Gnu - Autoconf - Patches mailing list archive at Nabble.com.





reply via email to

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