autoconf-patches
[Top][All Lists]
Advanced

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

Document and test AT_CHECK args shell execution environment. (was: docum


From: Ralf Wildenhues
Subject: Document and test AT_CHECK args shell execution environment. (was: document $at_status for use in RUN-IF-{PASS,FAIL} of AT_CHECK)
Date: Mon, 6 Sep 2010 08:12:16 +0200
User-agent: Mutt/1.5.20 (2010-04-22)

* Ralf Wildenhues wrote on Mon, Sep 06, 2010 at 08:08:55AM CEST:
>     autotest: document and test at_status semantics.

And while we are here, we could also document the execution environment
of the first, fifth, and sixth argument for AT_CHECK.  WDYT?

I think some of the tests may be relying on this implicitly already.
Haven't checked though.

Thanks,
Ralf

    Document and test AT_CHECK args shell execution environment.
    
    * doc/autoconf.texi (Writing Testsuites): Document that COMMANDS
    is run in a subshell, but RUN-IF-FAIL and RUN-IF-PASS are not.
    * tests/autotest.at (AT@&address@hidden execution environment): New
    test.
    * NEWS: Update.

diff --git a/NEWS b/NEWS
index a7f9068..43e3621 100644
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,8 @@ GNU Autoconf NEWS - User visible changes.
 ** Autotest testsuites should not contain long text lines any more, and be
    portable even when very many test groups are used.
 
-** The Autotest variable $at_status is documented now.
+** AT_CHECK semantics with respect to the Autotest variable $at_status and
+   shell execution environment of the arguments are documented now.
 
 
 * Major changes in Autoconf 2.67 (2010-07-21) [stable]
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index caa6309..023135f 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -24142,17 +24142,17 @@ Writing Testsuites
 @atindex{CHECK}
 @atindex{CHECK_UNQUOTED}
 @vrindex at_status
-Execute a test by performing given shell @var{commands}.  @var{commands}
-is output as-is, so shell expansions are honored.  These commands
-should normally exit with @var{status}, while producing expected
+Execute a test by performing given shell @var{commands} in a subshell.
address@hidden is output as-is, so shell expansions are honored.  These
+commands should normally exit with @var{status}, while producing expected
 @var{stdout} and @var{stderr} contents.  If @var{commands} exit with
 unexpected status 77, then the rest of the test group is skipped.  If
 @var{commands} exit with unexpected status 99, then the test group is
-immediately failed.  Otherwise, if this test
-fails, run shell commands @var{run-if-fail} or, if this test passes, run shell
-commands @var{run-if-pass}.  At the beginning of @var{run-if-fail} and
address@hidden, the status of @var{commands} is available in the
address@hidden shell variable.
+immediately failed.  Otherwise, if this test fails, run shell commands
address@hidden or, if this test passes, run shell commands
address@hidden, both inside the current shell execution environment.
+At the beginning of @var{run-if-fail} and @var{run-if-pass}, the status of
address@hidden is available in the @code{at_status} shell variable.
 
 This macro must be invoked in between @code{AT_SETUP} and @code{AT_CLEANUP}.
 
diff --git a/tests/autotest.at b/tests/autotest.at
index 725da38..ab04dbe 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -432,6 +432,25 @@ AT_CHECK([grep 'run-if-pass: 42' stdout], [], [ignore])
 ])
 
 
+AT_CHECK_AT_TEST([AT@&address@hidden execution environment],
+  [dnl The first test should fail, so we enter RUN-IF-FAIL.
+   AT_CHECK([test "$state" != before], [], [], [],
+           [state=run-if-fail
+            AT_CHECK([:]) dnl need this so we do not bail out at this point.
+            ])
+   dnl This should pass, so we enter RUN-IF-PASS.
+   AT_CHECK([test "$state" = run-if-fail], [], [], [], [],
+           [state=run-if-pass])
+   AT_CHECK([test "$state" = run-if-pass])
+   dnl However, COMMANDS are run inside a subshell, so do not change state.
+   AT_CHECK([state=broken; false], [], [], [],
+           [AT_CHECK([test "$state" = run-if-pass])])
+   AT_CHECK([state=broken], [], [], [], [],
+           [AT_CHECK([test "$state" = run-if-pass])])
+  ],
+  [], [], [], [], [], [], [state=before])
+
+
 AT_CHECK_AT_TEST([unquoted output],
   [m4_define([backtick], [`])
    a=a



reply via email to

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