From abb4422b67caf40a208cbfefe27f264215bd11e4 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 19 Oct 2007 05:33:55 -0600 Subject: [PATCH] Document and test AT_BANNER. * doc/autoconf.texi (Writing Testsuites): Document AT_BANNER. * tests/autotest.at (AT_CHECK_EGREP): Share between tests. (AT_CHECK_BANNERS): New test. Signed-off-by: Eric Blake --- ChangeLog | 5 ++++ doc/autoconf.texi | 12 +++++++- tests/autotest.at | 72 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 81 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c16c31e..1509c2ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-10-19 Eric Blake + Document and test AT_BANNER. + * doc/autoconf.texi (Writing Testsuites): Document AT_BANNER. + * tests/autotest.at (AT_CHECK_EGREP): Share between tests. + (AT_CHECK_BANNERS): New test. + Doc touchups. * doc/autoconf.texi (Text processing Macros) : Clarify and fix typos. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 324e9405..75b28657 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -19880,7 +19880,8 @@ for tests. Each such included file, or the remainder of @file{testsuite.at} if include files are not used, contain a sequence of test groups. Each test group begins with a call to @code{AT_SETUP}, then an arbitrary number of shell commands or calls to @code{AT_CHECK}, -and then completes with a call to @code{AT_CLEANUP}. +and then completes with a call to @code{AT_CLEANUP}. Multiple test +groups can be categorized by a call to @code{AT_BANNER}. @defmac AT_INIT (@ovar{name}) @atindex{INIT} @@ -19920,6 +19921,15 @@ diagnostics. @sp 1 +@defmac AT_BANNER (@var{test-category-name}) +@atindex{BANNER} +This macro identifies the start of a category of related test groups. +When the resulting @file{testsuite} is invoked with more than one test +group to run, its output will include a banner containing +@var{test-category-name} prior to any tests run from that category. The +banner should be no more than about 40 or 50 characters. +@end defmac + @defmac AT_SETUP (@var{test-group-name}) @atindex{SETUP} This macro starts a group of related tests, all to be executed in the diff --git a/tests/autotest.at b/tests/autotest.at index e3a46624..19e60b12 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -71,7 +71,17 @@ m4_pattern_allow([^AT_]) # AT_NO_CMDSUBST # -------------- m4_define([AT_NO_CMDSUBST], -[if (eval 'foo=$(echo bar) && test "$foo" = bar') >/dev/null 2>&1; then false; else :; fi]) +[if (eval 'foo=$(echo bar) && test "$foo" = bar') >/dev/null 2>&1; then ]dnl +[false; else :; fi]) + +# AT_CHECK_EGREP(PATTERN, STATUS, COUNT) +# -------------------------------------- +# Run grep -E, counting how many times PATTERN occurs in the file 'stdout', +# and expecting exit STATUS and output COUNT. +m4_define([AT_CHECK_EGREP], +[AT_CHECK([$EGREP -c '$1' stdout], [$2], [$3 +], [ignore]) +]) ## ------------------ ## @@ -370,6 +380,60 @@ AT_CHECK([(cd micro-suite.dir/1 && ./run MY_VAR='one space')], ]) +## -------- ## +## Banners. ## +## -------- ## +AT_SETUP([Banners]) +AT_KEYWORDS([autotest]) + +AT_DATA([b.at], +[[m4_define([AT_PACKAGE_STRING],[b]) +m4_define([AT_PACKAGE_BUGREPORT],[devnull]) +AT_INIT +AT_SETUP(zero)# 1 +AT_CHECK(:) +AT_CLEANUP + +AT_BANNER([first]) +AT_SETUP(one a)# 2 +AT_CHECK(:) +AT_CLEANUP +AT_SETUP(one b)# 3 +AT_CHECK(:) +AT_CLEANUP + +AT_BANNER([second]) +AT_SETUP(two a)# 4 +AT_CHECK(:) +AT_CLEANUP +AT_SETUP(two b)# 5 +AT_CHECK(:) +AT_CLEANUP +]]) +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_EGREP([$2], m4_if([$3], [0], [1], [0]), [$3]) +AT_CHECK_EGREP([$4], m4_if([$5], [0], [1], [0]), [$5]) +]) + +AT_CHECK_BANNERS([], [first], [1], [second], [1]) +AT_CHECK_BANNERS([-k zero], [first], [0], [second], [0]) +AT_CHECK_BANNERS([1], [first], [0], [second], [0]) +AT_CHECK_BANNERS([-2], [first], [1], [second], [0]) +AT_CHECK_BANNERS([-3], [first], [1], [second], [0]) +AT_CHECK_BANNERS([-k one], [first], [1], [second], [0]) +AT_CHECK_BANNERS([3-4], [first], [1], [second], [1]) +AT_CHECK_BANNERS([3-], [first], [1], [second], [1]) +AT_CHECK_BANNERS([-k a], [first], [1], [second], [1]) +AT_CHECK_BANNERS([4], [first], [0], [second], [0]) +AT_CHECK_BANNERS([4-], [first], [0], [second], [1]) +AT_CHECK_BANNERS([-k two], [first], [0], [second], [1]) +AT_CLEANUP + + ## --------- ## ## Keywords. ## ## --------- ## @@ -401,12 +465,6 @@ 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]) -# AT_CHECK_EGREP(PATTERN, STATUS, COUNT) -m4_define([AT_CHECK_EGREP], -[AT_CHECK([$EGREP -c '$1' stdout], $2, [$3 -], ignore) -]) - # AT_CHECK_KEYS(TESTSUITE-OPTIONS, PATTERN1, COUNT1, PATTERN2, COUNT2) m4_define([AT_CHECK_KEYS], [AT_CHECK([./k $1], 0, [stdout]) -- 2.47.2