2010-09-13 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+ autotest: document and test at_status semantics.
+ * doc/autoconf.texi (Writing Testsuites): Document $at_status.
+ * tests/autotest.at (at_status): New test.
+ * NEWS: Update.
+
doc: index entries for non-environment, non-output variables.
* doc/autoconf.texi: Clarify the meaning of the various variable
indices. Merge variable index `vr' into concept index using
@ovar{stderr}, @ovar{run-if-fail}, @ovar{run-if-pass})
@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
@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}.
+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.
This macro must be invoked in between @code{AT_SETUP} and @code{AT_CLEANUP}.
AT_CHECK([grep "inhibited subsequent" stderr], [], [ignore])],
[--errexit])
+
+AT_CHECK_AT_TEST([at_status],
+ [AT_CHECK([exit $mystatus], [$expected], [], [],
+ [AT_CHECK([echo run-if-fail: $at_status], [], [ignore])],
+ [AT_CHECK([echo run-if-pass: $at_status], [], [ignore])])
+ AT_CLEANUP
+ AT_SETUP([test with nested checks])
+ AT_CHECK([exit $mystatus], [$expected], [], [],
+ [AT_CHECK([exit $mystatus], [$expected], [], [],
+ [AT_CHECK([echo inner run-if-fail: $at_status], [],
+ [ignore])])])],
+ [], [], [stdout], [],
+[], [
+AT_CHECK([grep 'inner run-if-fail: 42' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x -v 1 mystatus=0 expected=0], [], [stdout])
+AT_CHECK([grep 'run-if-pass: 0' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x -v 1 mystatus=42 expected=0], [], [stdout])
+AT_CHECK([grep 'run-if-fail: 42' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x -v 1 mystatus=0 expected=42], [], [stdout])
+AT_CHECK([grep 'run-if-fail: 0' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x -v 1 mystatus=42 expected=42], [], [stdout])
+AT_CHECK([grep 'run-if-pass: 42' stdout], [], [ignore])
+],
+[-v mystatus=42 expected=1
+])
+
+
AT_CHECK_AT_TEST([unquoted output],
[m4_define([backtick], [`])
a=a