automake-patches
[Top][All Lists]
Advanced

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

Re: [FYI] New public temporary branch, about documentation for custom te


From: Stefano Lattarini
Subject: Re: [FYI] New public temporary branch, about documentation for custom test drivers
Date: Wed, 29 Jun 2011 15:54:44 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

On Tuesday 28 June 2011, Stefano Lattarini wrote:
> > Please go ahead after addressing my issues above.  The questions I wrote
> > should still be discussed (and might need changing stuff again) but that
> > shouldn't hold up the patch.
> >
> OK, will push this evening or tomorrow.
> 
I've pushed to 'test-protocols' now, and I've deleted the temporary branch
'GSoC/experimental/docs-custom-test-drivers'.  Attached is the patch that
has been pushed, for reference.

Regards,
  Stefano
From 1402741313cf6c2fe8611eb294f9a8111c994a32 Mon Sep 17 00:00:00 2001
Message-Id: <address@hidden>
From: Stefano Lattarini <address@hidden>
Date: Wed, 22 Jun 2011 21:59:34 +0200
Subject: [PATCH] docs: document custom test drivers and protocols

* doc/automake.texi (Simple Tests): Note that the TESTS_ENVIRONMENT
use suggested here is not portable to 'parallel-tests'.
(Simple Tests using parallel-tests): Document new restrictions on
the uses of TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
(Custom Test Drivers): New section and node.
(Overview of Custom Test Drivers Support): New subsection.
(Declaring Custom Test Drivers in @file{Makefile.am}): Likewise.
(APIs for Custom Test Drivers): Likewise.
(Options): Update description of color-tests.
* lib/am/check ($(TEST_SUITE_LOG)): Remove comments that have been
moved into the manual.
(recheck, recheck-html): Minor adjustments to better conform to the
documentation (this should cause no semantic changes w.r.t. the
former behaviour); minor improvements and extensions to existing
comments.
* tests/test-driver-create-log-dir.test: New test.
* tests/test-driver-strip-vpath.test: Likewise.
* tests/test-driver-global-log.test: Likewise.
* tests/test-driver-recheck.test: Likewise.
* tests/Makefile.am (TESTS): Update.
---
 ChangeLog                             |   24 ++
 doc/automake.texi                     |  378 +++++++++++++++++++++++++++++++--
 lib/Automake/tests/Makefile.in        |    2 +-
 lib/am/check.am                       |   15 +-
 tests/Makefile.am                     |    4 +
 tests/Makefile.in                     |    6 +-
 tests/test-driver-create-log-dir.test |   74 +++++++
 tests/test-driver-global-log.test     |  110 ++++++++++
 tests/test-driver-recheck.test        |  126 +++++++++++
 tests/test-driver-strip-vpath.test    |   96 +++++++++
 10 files changed, 804 insertions(+), 31 deletions(-)
 create mode 100755 tests/test-driver-create-log-dir.test
 create mode 100755 tests/test-driver-global-log.test
 create mode 100755 tests/test-driver-recheck.test
 create mode 100755 tests/test-driver-strip-vpath.test

diff --git a/ChangeLog b/ChangeLog
index c99944a..6203f89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2011-06-29  Stefano Lattarini  <address@hidden>
+
+       docs: document custom test drivers and protocols
+       * doc/automake.texi (Simple Tests): Note that the TESTS_ENVIRONMENT
+       use suggested here is not portable to 'parallel-tests'.
+       (Simple Tests using parallel-tests): Document new restrictions on
+       the uses of TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
+       (Custom Test Drivers): New section and node.
+       (Overview of Custom Test Drivers Support): New subsection.
+       (Declaring Custom Test Drivers in @file{Makefile.am}): Likewise.
+       (APIs for Custom Test Drivers): Likewise.
+       (Options): Update description of color-tests.
+       * lib/am/check ($(TEST_SUITE_LOG)): Remove comments that have been
+       moved into the manual.
+       (recheck, recheck-html): Minor adjustments to better conform to the
+       documentation (this should cause no semantic changes w.r.t. the
+       former behaviour); minor improvements and extensions to existing
+       comments.
+       * tests/test-driver-create-log-dir.test: New test.
+       * tests/test-driver-strip-vpath.test: Likewise.
+       * tests/test-driver-global-log.test: Likewise.
+       * tests/test-driver-recheck.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
 2011-06-29   Stefano Lattarini  <address@hidden>
 
        docs: explain why AM_TESTS_ENVIRONMENT must be semicolon-terminated
diff --git a/doc/automake.texi b/doc/automake.texi
index 481ada4..a26f2a5 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -319,9 +319,23 @@ Support for test suites
 
 * Simple Tests::                Listing programs and scripts in @code{TESTS}
 * Simple Tests using parallel-tests::  More powerful test driver
+* Custom Test Drivers::         Writing and using custom test drivers
 * DejaGnu Tests::               Interfacing with the external testing framework
 * Install Tests::               Running tests on installed packages
 
+Custom Test Drivers
+
+* Overview of Custom Test Drivers Support::
+* Declaring Custom Test Drivers::
+* API for Custom Test Drivers::
+
+API for Custom Test Drivers
+
+* Command-line arguments for test drivers::
+* Log files generation and test results recording::
+* Testsuite progress output::
+* HTML generation from testsuite logs::
+
 Changing Automake's Behavior
 
 * Options generalities::        Semantics of Automake option
@@ -8641,6 +8655,7 @@ are very similar.
 @menu
 * Simple Tests::                Listing programs and scripts in @code{TESTS}
 * Simple Tests using parallel-tests::  More powerful test driver
+* Custom Test Drivers::         Writing and using custom test drivers
 * DejaGnu Tests::               Interfacing with the external testing framework
 * Install Tests::               Running tests on installed packages
 @end menu
@@ -8670,7 +8685,9 @@ given test program exits with a status of 77, then its 
result is ignored
 in the final count.  This feature allows non-portable tests to be
 ignored in environments where they don't make sense.
 
address@hidden tests and color-tests}
 @vindex AM_COLOR_TESTS
address@hidden Colorized testsuite output
 If the Automake option @code{color-tests} is used (@pxref{Options})
 and standard output is connected to a capable terminal, then the test
 results and the summary are colored appropriately.  The user can disable
@@ -8699,10 +8716,12 @@ TESTS_ENVIRONMENT = $(PERL) -Mstrict -w
 TESTS = foo.pl bar.pl baz.pl
 @end example
 
-Note that the @option{parallel-tests} driver provides a more elegant
-way to achieve the same effect, freeing the @code{TESTS_ENVIRONMENT}
-variable for the user to override (@pxref{Simple Tests using
-parallel-tests}).
+It's important to note that this last use of @code{TESTS_ENVIRONMENT}
+is invalid when the @option{parallel-tests} option is active; however,
+the @option{parallel-tests} driver provides a more elegant way to
+achieve the same effect, with the further benefit of freeing the
address@hidden variable for the user
+(@pxref{Simple Tests using parallel-tests}).
 
 
 @cindex Tests, expected failure
@@ -8747,7 +8766,9 @@ for exceptional failures.  Similar to the simple test 
driver,
 the @code{check_*} variables are honored, and the environment variable
 @env{srcdir} is set during test execution. Also, @code{TESTS_ENVIRONMENT}
 is still honored, but is complemented by a new developer-reserved variable
address@hidden (described below).
address@hidden (described below), and its allowed uses are
+somewhat restricted (other features of the @option{parallel-tests} driver
+compensate for this, though).
 
 This test driver is still experimental and may undergo changes in order
 to satisfy additional portability requirements.
@@ -8820,28 +8841,47 @@ and @samp{./wrapper-script -d baz} to produce 
@file{foo.log},
 but should be reserved for the user.
 
 @vindex AM_TESTS_ENVIRONMENT
-The @code{AM_TESTS_ENVIRONMENT} variable can be used to run initialization
-code and set environment variables for the tests' runs.  The user can
-still employ the @code{TESTS_ENVIRONMENT} variable to override settings
-from @code{AM_TESTS_ENVIRONMENT}; for that to work portably, however,
-the contents of a non-empty @code{AM_TESTS_ENVIRONMENT} @emph{must} be
-terminated by a semicolon.  Here is an example of a slightly elaborate
-definition:
+The @code{AM_TESTS_ENVIRONMENT} and @code{TESTS_ENVIRONMENT} variables can
+be used to run initialization code and set environment variables for the
+test scripts.  The former variable is developer-reserved, and can be
+defined in the @file{Makefile.am}, while the latter is reserved for the
+user, which can employ it to extend or override the settings in the
+former; for this to work portably, however, the contents of a non-empty
address@hidden @emph{must} be terminated by a semicolon.
 
 @example
 AM_TESTS_ENVIRONMENT = \
 ## Some environment initializations are kept in a separate shell file
-## `tests-env.sh', which can make it easier to also run tests from the
-## command line.
+## `tests-env.sh', which can make it easier to also run tests from
+## the command line.
   . $(srcdir)/tests-env.sh; \
-## On Solaris, prefer more POSIX-compliant versions of the standard tools
-## by default.
+## On Solaris, prefer more POSIX-compliant versions of the standard
+## tools by default.
   if test -d /usr/xpg4/bin; then \
     PATH=/usr/xpg4/bin:$$PATH; export PATH; \
   fi;
 @c $$ restore font-lock
 @end example
 
+It's important to note that, differently from what we've seen for the
+serial testsuite driver (@pxref{Simple Tests using parallel-tests}), the
address@hidden and @code{TESTS_ENVIRONMENT} variables
address@hidden be use to define a custom test driver; the
address@hidden and @code{LOG_FLAGS} (or their extension-specific
+counterparts) should be used instead:
+
address@hidden
+## This is WRONG!
+AM_TESTS_ENVIRONMENT = PERL5LIB='$(srcdir)/lib' $(PERL) -Mstrict -w
address@hidden example
+
address@hidden
+## Do this instead.
+AM_TESTS_ENVIRONMENT = PERL5LIB='$(srcdir)/lib'; export PERL5LIB;
+LOG_COMPILER = $(PERL)
+AM_LOG_FLAGS = -Mstrict -w
address@hidden example
+
 @trindex mostlyclean
 @trindex check-html
 @vindex RST2HTML
@@ -8984,6 +9024,306 @@ semantics of FreeBSD and OpenBSD @command{make} 
conflict with this).
 In case of doubt you may want to require to use GNU @command{make},
 or work around the issue with inference rules to generate the tests.
 
address@hidden Custom Test Drivers
address@hidden Custom Test Drivers
+
address@hidden
+* Overview of Custom Test Drivers Support::
+* Declaring Custom Test Drivers::
+* API for Custom Test Drivers::
address@hidden menu
+
address@hidden Overview of Custom Test Drivers Support
address@hidden Overview of Custom Test Drivers Support
+
+Starting form Automake version 1.12, the @option{parallel-tests} harness
+allows the package authors to use third-party custom test drivers, in case
+the
address@hidden FIXME: this should become "default ones" once we have TAP and 
Subunit
+default one is inadequate for their purposes.
address@hidden FIXME: add this once we have TAP and Subunit
address@hidden "or do not support their testing protocol of choice."
+
+A custom test driver is expected to properly run the test programs
+passed to it, including the command-line arguments passed to it,
+to analyze their execution and outcome, to create the @file{.log}
+files associated to these test runs, and to display the test results
+on the console.  It is responsibility of the author of the test driver
+to ensure that it implements all the above steps meaningfully and
+correctly; Automake isn't and can't be of any help here.  On the other
+hand, the Automake-provided code for testsuite summary generation offers
+support for test drivers allowing several test results per test script,
+if they take care to register such results properly (@pxref{Log files
+generation and test results recording}).
+
+The exact details of how test scripts' results are to be determined and
+analyzed is left to the individual drivers.  Some drivers might only
+consider the test script exit status (this is done for example by the
+default test driver used by the @option{parallel-tests} harness, described
+in the previous section).  Other drivers might implement more complex and
+advanced test protocols, which might require them to parse and interpreter
+the output emitted by the test script they're running (examples of such
+protocols are TAP and SubUnit).
+
+It's very important to note that, even when using custom test drivers,
+most of the @option{parallel-tests} infrastructure described in the
+previous section remains in place; this includes:
+
address@hidden
address@hidden
+concurrency through the use of  @command{make}'s option @option{-j};
address@hidden
+per-test @file{.log} files, and generation of a summary @file{.log}
+file from them;
address@hidden
address@hidden target and lazy reruns of tests;
address@hidden
+inter-test dependencies;
address@hidden
+support for @code{check_*} variables (@code{check_PROGRAMS},
address@hidden, ...);
address@hidden
+use of @code{VERBOSE} environment variable to get verbose output on
+testsuite failures;
address@hidden
+definition and honoring of @code{TESTS_ENVIRONMENT} and
address@hidden variables;
address@hidden
+definition of generic and extension-specific @code{LOG_COMPILER} and
address@hidden variables.
address@hidden itemize
+
address@hidden
+On the other hand, the exact semantics of how (and if)
address@hidden, @code{XFAIL_TESTS}, and hard errors are supported
+and handled is left to the individual test drivers.
+
address@hidden TODO: We should really add a working example in the doc/ 
directory,
address@hidden TODO: and reference if from here.
+
address@hidden Declaring Custom Test Drivers
address@hidden Declaring Custom Test Drivers
+
address@hidden _LOG_DRIVER
address@hidden _LOG_DRIVER_FLAGS
address@hidden LOG_DRIVER
address@hidden LOG_DRIVER_FLAGS
address@hidden @var{ext}_LOG_DRIVER
address@hidden @var{ext}_LOG_DRIVER_FLAGS
address@hidden address@hidden
address@hidden AM_LOG_DRIVER_FLAGS
+Custom testsuite drivers are declared by defining the make variables
address@hidden or @address@hidden (where @var{ext} must
+be declared in @code{TEST_EXTENSIONS}).  They must be defined to
+programs or scripts that will be used to drive the execution, logging,
+and outcome report of the tests with corresponding extensions (or of
+those with no registered extension in the case of @code{LOG_DRIVER}).
+Clearly, multiple distinct test drivers can be declared in the same
address@hidden  Note moreover that the @code{LOG_DRIVER} variables
+are @emph{not} a substitute for the @code{LOG_COMPILER} variables: the
+two sets of variables can, and often do, usefully and legitimately
+coexist.
+
address@hidden TODO: We should really be able to point to a clarifying example 
here!
+
+The developer-reserved variable @code{AM_LOG_DRIVER_FLAGS} and the
+user-reserved variable @code{LOG_DRIVER_FLAGS} can be used to define
+flags that will be passed to each invocation of @code{LOG_DRIVER}
+(with the user-defined flags obviously taking precedence over the
+developer-reserved ones).  Similarly, for each extension @var{ext}
+declared in @code{TEST_EXTENSIONS}, flags listed in
address@hidden@var{ext}_LOG_DRIVER_FLAGS} and
address@hidden@var{ext}_LOG_DRIVER_FLAGS} will be passed to
+invocations of @address@hidden
+
address@hidden API for Custom Test Drivers
address@hidden API for Custom Test Drivers
+
+Note that @emph{the APIs described here are still somewhat experimental},
+and might undergo changes and tightenings in the future, to accommodate
+for new features or to satisfy additional portability requirements.
+
+The main characteristic of these APIs is that they are designed to share
+as much infrastructure, semantics, and implementation details as possible
+with the @option{parallel-tests} harness and its default driver.  So
+everything said in the previous section should apply here too, unless
+explicitly stated otherwise.
+
address@hidden
+* Command-line arguments for test drivers::
+* Log files generation and test results recording::
+* Testsuite progress output::
+* HTML generation from testsuite logs::
address@hidden menu
+
address@hidden Command-line arguments for test drivers
address@hidden Command-line arguments for test drivers
+
+A custom driver can rely on various command-line options and arguments
+being passed to it automatically by the Automake's @option{parallel-tests}
+harness.  It is @emph{mandatory} that it understands all of them (even
+if the exact interpretation of the associated semantics can legitimately
+change between a test driver and another, and even be a no-op in some
+drivers).
+
address@hidden
+Here is the list of options:
+
address@hidden @option
address@hidden address@hidden
+The name of the test, with VPATH prefix (if any) removed.  This can have a
+suffix and a directory component (as in e.g., @file{sub/foo.test}), and is
+mostly meant to be used in console reports about testsuite advancements and
+results (@pxref{Testsuite progress output}).
address@hidden address@hidden
+The log file the test driver must create.  If it has a directory component
+(as in e.g., @file{sub/foo.log}), the Automake harness will ensure that
+such directory exist @emph{before} the test driver is called.
address@hidden address@hidden|address@hidden
+Whether the console output should be colorized or not (@pxref{Simple
+tests and color-tests}, to learn when this option gets activated and
+when it doesn't).
address@hidden address@hidden|address@hidden
+Whether the tested program is expected to fail.
address@hidden address@hidden|address@hidden
+Whether ``hard errors'' in the tested program should be treated differently
+from normal failures or not (the default should be @code{yes}).  The exact
+meaning of ``hard error'' is highly dependent from the test protocols or
+conventions in use.
address@hidden --
+Explicitly terminate the list of options.
address@hidden table
+
+The first of the remaining arguments passed to the test driver is the
+program to be run, and the other arguments are command-line options
+and arguments for this program.
+
+Note that the exact semantics attached to the @option{--color-tests},
address@hidden and @option{--enable-hard-errors} options are
+left up to the individual test drivers.  Still, having a behaviour
+compatible or at least similar to that provided by the default
address@hidden driver is advised, as that would offer a better
+consistency and a more pleasant user experience.
+
address@hidden Log files generation and test results recording
address@hidden Log files generation and test results recording
+
+The test driver must correctly generate the file specified by the
address@hidden option (of course even when the tested program
+fails or crashes).  This file is quite free-form, but still it has
+to conform to the following conventions, in order to work with the
address@hidden harness and take advantage of its features.
+
address@hidden @bullet
address@hidden
address@hidden Global test script result
address@hidden Test result, global
+The @emph{global test result} for the whole test script must be placed
+in the first line of the @file{.log} file.
address@hidden The following semantics is checked by tests 
'test-driver-recheck.test'
address@hidden and 'test-driver-global-log.test'.  Please keep them in sync 
whenever
address@hidden the following is changed.
+If this line does not begin with either @code{PASS:}, @code{XFAIL:} or
address@hidden:}, the test script will be considered failed, and it will be
+re-run by @code{make recheck}.  Also, if this line does not begin with
+either @code{PASS:} or @code{XFAIL:}, the content of the @file{.log} file
+will be copied into the global @file{test-suite.log} (in order to help in
+debugging and bug-report analysis).
+
address@hidden
address@hidden Single test case result
address@hidden Test result, single
address@hidden @code{:test-result:} reStructuredText field
address@hidden  reStructuredText field, @code{:test-result:}
+One of the main features of the new testsuite harness is the ability to
+support test protocols that allow a single test script to run more
+test cases, @emph{each with its distinct result}.  In order for the
+testsuite summary to be correct in this case, the test driver must
+register @emph{each} such result in the generated @file{.log} file, using
+the @code{:test-result:} reStructuredText field.  Otherwise, only the
+global test result will be considered (as it is the case of the default
address@hidden driver).
+
address@hidden Keep this in sync with lib/am/check-am:$(TEST_SUITE_LOG).
+The only recognized test results are currently @code{PASS}, @code{XFAIL},
address@hidden, @code{FAIL} and @code{XPASS}.  These results, when declared
+with @code{:test-result:}, can be optionally followed by text holding
+the name and/or a brief description of the corresponding test; the
address@hidden harness will ignore such extra text when
+generating @file{test-suite.log} and preparing the testsuite summary.
+
+For example, if a @file{.log} file contains the following lines:
+
address@hidden
+:test-result: PASS server starts
+:test-result: PASS HTTP/1.1 request
+:test-result: FAIL HTTP/1.0 request
+:test-result: SKIP HTTPS request (TLS library wasn't available)
+:test-result: PASS server stops
address@hidden example
+
address@hidden
+it means that the corresponding test script contributes with five test
+results to the testsuite summary (three of these tests being successful,
+one failed, and one skipped).
+
address@hidden FIXME: currently, the @code{:test-result:} field is recognized 
anywhere
address@hidden in the @file{.log} file; this is possibly prone to generating 
spurious
address@hidden results, in case of verbose tests.  We should allow a special
address@hidden @code{:test-result:} that stops any further parsing (maybe a line
address@hidden @code{:test-result:END} will do?).
+
address@hidden itemize
+
+Finally, note that the declaration of the global test result in the first
+line, apart from being needed for backward-compatibility with the default
address@hidden driver, can be useful also for test protocols
+that allow more test results per test script: using it, a custom test
+driver is allowed to decide what the global outcome of the test script
+is in case of conflicting test results within the script.  For example,
+if a test script reports 8 successful test cases and 2 skipped test
+cases, some drivers might report that globally as a SKIP, while others
+as a PASS.
+
address@hidden Testsuite progress output
address@hidden Testsuite progress output
+
+A custom test driver also has the task of displaying, on the standard
+output, the test results as soon as they become available.  Depending on
+the protocol in use, it can also display the reasons for failures and
+skips, and, more generally, any useful diagnostic output (but remember
+that each line on the screen is precious, so that cluttering the screen
+with overly verbose information is bad idea).  The exact format of this
+progress output is left up to the test driver; in fact, a custom test
+driver might @emph{theoretically} even decide not to do any such report,
+leaving it all to the testsuite summary (that would be a very lousy idea,
+of course, and serves only to illustrate the flexibility that is
+granted here).
+
+Remember that consistency is good; so, if possible, try to be consistent
+with the output of the built-in Automake test drivers, providing a similar
+``look & feel''.  In particular, the testsuite progress output should be
+colorized when the @option{--color-tests} is passed to the driver.  On the
+other end, if you are using a known and widespread test protocol with
+well-established implementations, being consistent with those
+implementations' output might be a good idea too.
+
address@hidden TODO: Give an example, maybe inspired to py.test-style output.
address@hidden TODO: That is a good idea because it shows a test driver that 
allows
address@hidden TODO: for different levels of verbosity in the progress output 
(could
address@hidden TODO: be implemented either using a driver cmdline flag, or an
address@hidden TODO: environment variable, or both).
+
address@hidden HTML generation from testsuite logs
address@hidden HTML generation from testsuite logs
+
+If HTML testsuite output (with @code{check-html}) is to be supported,
+the generated @file{.log} files must contain syntactically valid
+reStructuredText (among the other things, this means that every
address@hidden:test-result:} line must be followed by a blank line).  If this
+is not the case, the HTML generation will not work, although all the
+other functionalities of the Automake testsuite harness should remain
+untouched, and continue to work correctly.
 
 @node DejaGnu Tests
 @section DejaGnu Tests
@@ -9240,8 +9580,10 @@ in the first few lines of the @file{NEWS} file.
 @item @option{color-tests}
 @cindex Option, @option{color-tests}
 @opindex color-tests
-Cause output of the simple test suite (@pxref{Simple Tests}) to be
-colorized on capable terminals.
+Cause output of the simple and parallel test suites (see @ref{Simple Tests}
+and @ref{Simple Tests using parallel-tests}) and of properly-written custom
+test drivers (@pxref{Custom Test Drivers}) to be colorized on capable
+terminals.
 
 @item @option{dejagnu}
 @cindex Option, @option{dejagnu}
diff --git a/lib/Automake/tests/Makefile.in b/lib/Automake/tests/Makefile.in
index 9c344f5..e1867fb 100644
--- a/lib/Automake/tests/Makefile.in
+++ b/lib/Automake/tests/Makefile.in
@@ -464,7 +464,7 @@ recheck recheck-html:
        list=`for f in $$list; do                                       \
                test -f $$f || continue;                                \
                if test -r $$f && read line < $$f; then                 \
-                 case $$line in FAIL*|XPASS*) echo $$f;; esac;         \
+                 case $$line in PASS:*|XFAIL:*|SKIP:*);; *) echo $$f;; esac; \
                else echo $$f; fi;                                      \
              done | tr '\012\015' '  '`;                               \
        list=`echo "$$list" | sed 's/ *$$//'`;                          \
diff --git a/lib/am/check.am b/lib/am/check.am
index 062c59c..b02d6c5 100644
--- a/lib/am/check.am
+++ b/lib/am/check.am
@@ -205,16 +205,8 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
          echo;                                                         \
          echo ".. contents:: :depth: 2";                               \
          echo;                                                         \
-## Here we assume that the test driver writes a proper summary for the
-## test script on the first line.  Requiring this is not a limitation,
-## but a feature, since this way a custom test driver is allowed to decide
-## what the outcome is in case of conflicting testcase results in a test
-## script.  For example, if a test script reports 8 successful testcases
-## and 2 skipped testcases, some drivers might report that globally as a
-## SKIP, while others as a PASS.
-## FIXME: This should be documented in the automake manual.  The above
-## FIXME: explanation is indeed more appropriate for the manual than for
-## FIXME: comments in code.
+## Here we assume that the test driver writes a proper "summarizing
+## result" for the test script on the first line.
          for f in $$list; do                                           \
            test -r $$f && read line < $$f || line=;                    \
            case $$line in                                              \
@@ -317,7 +309,8 @@ recheck recheck-html:
 ## test script on the first line.  See the comments in the rules of
 ## $(TEST_SUITE_LOG) above for why we consider this acceptable and even
 ## advisable.
-                 case $$line in FAIL*|XPASS*) echo $$f;; esac;         \
+                 case $$line in PASS:*|XFAIL:*|SKIP:*);; *) echo $$f;; esac; \
+## A test whose log is unreadable is to be considered failed.
                else echo $$f; fi;                                      \
              done | tr '\012\015' '  '`;                               \
 ## This apparently useless munging helps to avoid a nasty bug (a
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b49e754..0b83b0c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -738,6 +738,10 @@ test-driver-custom-multitest-recheck.test \
 test-driver-custom-multitest-recheck2.test \
 test-driver-custom-html.test \
 test-driver-custom-no-html.test \
+test-driver-create-log-dir.test \
+test-driver-global-log.test \
+test-driver-recheck.test \
+test-driver-strip-vpath.test \
 test-driver-fail.test \
 parse.test \
 percent.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 0219eea..193fc95 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -998,6 +998,10 @@ test-driver-custom-multitest-recheck.test \
 test-driver-custom-multitest-recheck2.test \
 test-driver-custom-html.test \
 test-driver-custom-no-html.test \
+test-driver-create-log-dir.test \
+test-driver-global-log.test \
+test-driver-recheck.test \
+test-driver-strip-vpath.test \
 test-driver-fail.test \
 parse.test \
 percent.test \
@@ -1510,7 +1514,7 @@ recheck recheck-html:
        list=`for f in $$list; do                                       \
                test -f $$f || continue;                                \
                if test -r $$f && read line < $$f; then                 \
-                 case $$line in FAIL*|XPASS*) echo $$f;; esac;         \
+                 case $$line in PASS:*|XFAIL:*|SKIP:*);; *) echo $$f;; esac; \
                else echo $$f; fi;                                      \
              done | tr '\012\015' '  '`;                               \
        list=`echo "$$list" | sed 's/ *$$//'`;                          \
diff --git a/tests/test-driver-create-log-dir.test 
b/tests/test-driver-create-log-dir.test
new file mode 100755
index 0000000..5713b92
--- /dev/null
+++ b/tests/test-driver-create-log-dir.test
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: if a log file has a directory component (as in
+# e.g., `sub/foo.log'), the Automake test harness must ensure that
+# directory exists before calling any custom test driver.
+
+parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# The extra `.' components below are meant.
+TESTS = sub/foo sub/subsub/bar.test ././sub1/./baz
+$(TESTS):
+LOG_DRIVER = $(srcdir)/checkdir-driver
+TEST_LOG_DRIVER = $(LOG_DRIVER)
+EXTRA_DIST = checkdir-driver
+
+check-local: $(TEST_SUITE_LOG)
+       test -d sub
+       test -d sub1
+       test -d sub/subsub
+       test -f sub/foo.log
+       test -f sub/subsub/bar.log
+       test -f sub1/baz.log
+END
+
+cat > checkdir-driver <<'END'
+#! /bin/sh
+set -e
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --test-name|--expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+echo "log: $log_file" # For debugging.
+case $log_file in */*);; *) exit 1;; esac
+dir=`expr "$log_file" : '\(.*\)/[^/]*'`
+echo "dir: $dir" # For debugging.
+test -d "$dir" || exit 1
+echo dummy > "$log_file"
+END
+chmod a+x checkdir-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/tests/test-driver-global-log.test 
b/tests/test-driver-global-log.test
new file mode 100755
index 0000000..cdaaff6
--- /dev/null
+++ b/tests/test-driver-global-log.test
@@ -0,0 +1,110 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the output of testcases having a global outcome that is not
+# "PASS" or "XFAIL" is copied in the global 'test-suite.log'.
+
+parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+# The :test-result: fields should be irrelevant for the decision
+# of whether a test output is to be copied in the test-suite.log.
+cat > pass.test <<END
+PASS: pass.test
+:test-result: SKIP
+:test-result: FAIL
+:test-result: XFAIL
+:test-result: XPASS
+:test-result: ERROR
+not seen (pass)
+END
+
+cat > xfail.test <<'END'
+XFAIL: xfail.test
+not seen (xfail)
+END
+
+echo SKIP: skip.test > skip.test
+echo FAIL: fail.test > fail.test
+echo XPASS: xpass.test > xpass.test
+echo :test-result: PASS > fake-pass.test
+echo "$tab $tab$tab" > empty.test
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = ./dummy-driver
+TESTS = pass.test skip.test fail.test xfail.test xpass.test \
+        fake-pass.test empty.test
+END
+
+
+cat > dummy-driver <<'END'
+#!/bin/sh
+set -e
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --test-name) test_name=$2; shift;;
+    --expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+cp $1 $log_file
+END
+chmod a+x dummy-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE check && { cat test-suite.log; Exit 1; }
+cat test-suite.log
+grep '^SKIP: skip\.test$' test-suite.log
+grep '^FAIL: fail.test$' test-suite.log
+grep '^XPASS: xpass.test$' test-suite.log
+grep '^:test-result: PASS$' test-suite.log
+grep "^$tab $tab$tab$" test-suite.log
+$EGREP 'not seen' test-suite.log && Exit 1
+test `grep -c ':test-result:' test-suite.log` -eq 1
+
+cat > pass.test <<END
+PASS: pass.test
+:test-result: SKIP
+:test-result: XFAIL
+not seen (pass)
+END
+
+cat > xfail.test <<END
+XFAIL: xfail.test
+:test-result: SKIP
+:test-result: PASS
+not seen (xfail)
+END
+
+TESTS='pass.test skip.test xfail.test' $MAKE -e check \
+  || { cat test-suite.log; Exit 1; }
+cat test-suite.log
+grep '^SKIP: skip\.test$' test-suite.log
+$EGREP ':test-result:|not seen' test-suite.log && Exit 1
+
+:
diff --git a/tests/test-driver-recheck.test b/tests/test-driver-recheck.test
new file mode 100755
index 0000000..2ae75b9
--- /dev/null
+++ b/tests/test-driver-recheck.test
@@ -0,0 +1,126 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test the "make recheck" semantics for custom test driver, as
+# documented in detail in the Automake manual.
+
+parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+LOG_DRIVER = ./dummy-driver
+TEST_EXTENSIONS =
+TESTS =
+END
+
+rechecked=''
+notrechecked=''
+
+for R in PASS XFAIL SKIP; do
+  echo $R: > $R-1
+  echo " $R:" > $R-2
+  echo $R:foo > $R-3
+  echo "$tab $R: bar baz" > $R-4
+  # The :test-result: fields should be irrelevant for the decision of
+  # whether "make recheck" should or should not re-run a test.
+  unindent > $R-5 <<END
+    $R:
+    :test-result: FAIL
+    :test-result: XPASS
+    :test-result: ERROR
+END
+  notrechecked="$notrechecked $R-1 $R-2 $R-3 $R-4 $R-5"
+  echo $R > BAD-$R-1
+  echo $R. > BAD-$R-2
+  echo :$R: > BAD-$R-3
+  echo $R asd > BAD-$R-4
+  rechecked="$rechecked BAD-$R-1 BAD-$R-2 BAD-$R-3 BAD-$R-4"
+done
+
+for R in FAIL XPASS UNKNOWN; do
+  echo $R: > $R-1
+  echo $R:foo > $R-2
+  echo $R: bar baz > $R-3
+  echo $R > $R-4
+  echo $R asd > $R-5
+  # The :test-result: fields should be irrelevant for the decision of
+  # whether "make recheck" should or should not re-run a test.
+  unindent > $R-6 <<END
+    :test-result: PASS
+    :test-result: SKIP
+    :test-result: XFAIL
+END
+  (echo $R: && cat $R-6) > $R-7
+  rechecked="$rechecked $R-1 $R-2 $R-3 $R-4 $R-5 $R-6 $R-7"
+done
+
+: > EMPTY
+echo "  $tab $tab" > WHITE
+rechecked="$rechecked EMPTY WHITE"
+
+tests="$rechecked $notrechecked"
+
+for t in $tests; do echo $t; done | sed 's/.*/TESTS += &/' >> Makefile.am
+
+cat Makefile.am # For debugging.
+
+cat > dummy-driver <<'END'
+#!/bin/sh
+set -e
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --test-name) test_name=$2; shift;;
+    --expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+: > $test_name.run
+cp $1 $log_file
+END
+chmod a+x dummy-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# The ':test-result:' fields should be ignored by "make recheck",
+# but should cause the testsuite report to detect errors.
+$MAKE check && Exit 1
+ls -l
+for t in $tests; do test -f $t.run; done
+rm -f *.run
+
+# But now the tests that actually get re-run have only ':test-result:'
+# fields indicating success, so "make recheck" must pass.  Still, the
+# next "make recheck" call should still re-run the same set of tests.
+for iteration in 1 2; do
+  $MAKE recheck
+  ls -l
+  for t in $rechecked; do test -f $t.run; done
+  for t in $notrechecked; do test ! -r $t.run; done
+  rm -f *.run
+done
+
+:
diff --git a/tests/test-driver-strip-vpath.test 
b/tests/test-driver-strip-vpath.test
new file mode 100755
index 0000000..f1b316c
--- /dev/null
+++ b/tests/test-driver-strip-vpath.test
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Custom test drivers: check that the test name passed to the test
+# driver has any VPATH prefix stripped.
+
+parallel_tests=yes
+. ./defs || Exit 1
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+mkdir src build
+mv install-sh missing configure.in src
+rm -f depcomp
+
+cd src
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# The directories of the `bar.test' and `baz.test' tests are deliberately
+# called as the source directory, to verify that the VPATH-stripping code
+# doesn't get too easily confused.
+# The $(empty) are for eliciting VPATH rewrites on make implementations
+# that support it (e.g., Solaris make), to improve coverage.
+empty =
+TESTS = $(empty) foo.test src/bar.test ./src/baz.test $(empty)
+$(TESTS):
+TEST_LOG_DRIVER = $(srcdir)/checkstrip-driver
+EXTRA_DIST = checkstrip-driver
+END
+
+cat > checkstrip-driver <<'END'
+#! /bin/sh
+set -e
+while test $# -gt 0; do
+  case $1 in
+    --log-file) log_file=$2; shift;;
+    --test-name) test_name=$2; shift;;
+    --expect-failure|--color-tests|--enable-hard-errors) shift;;
+    --) shift; break;;
+     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+  esac
+  shift
+done
+echo "test name: $test_name" # For debugging.
+case $test_name in
+  foo.test|./foo.test|src/ba[rz].test|./src/ba[rz].test);;
+  *) exit 1;;
+esac
+echo dummy > "$log_file"
+END
+chmod a+x checkstrip-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+cd ..
+
+mkdir build1
+cd build1
+../src/configure
+# "$MAKE -n" is for debugging, should highlight any VPATH rewrite.
+$MAKE -n check
+$MAKE check
+cd ..
+
+mkdir build2
+cd build2
+"$ocwd"/src/configure
+# "$MAKE -n" is for debugging, should highlight any VPATH rewrite.
+$MAKE -n check
+$MAKE check
+cd ..
+
+cd src
+./configure
+$MAKE distcheck
+
+:
-- 
1.7.2.3


reply via email to

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