2010-09-13 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+ 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@&t@_CHECK execution environment): New
+ test.
+ * NEWS: Update.
+
autotest: document and test at_status semantics.
* doc/autoconf.texi (Writing Testsuites): Document $at_status.
* tests/autotest.at (at_status): New test.
** 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]
@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.
+@var{commands} 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
-@var{run-if-pass}, the status of @var{commands} is available in the
-@code{at_status} shell variable.
+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}, both inside the current shell execution environment.
+At the beginning of @var{run-if-fail} and @var{run-if-pass}, the status of
+@var{commands} is available in the @code{at_status} shell variable.
This macro must be invoked in between @code{AT_SETUP} and @code{AT_CLEANUP}.
])
+AT_CHECK_AT_TEST([AT@&t@_CHECK 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