I've just checked in support for defining testsuites within library
documentation. The idea is based on the test case descriptions in the
MultiArray library, where Ron Garcia gives short descriptions of the
purpose of each testcase. The testsuite XML format supports generation of
documentation similar to that in the MultiArray library but also supports
the creation of testcases from code snippets (<programlisting> elements)
and generation of the Jamfiles needed to run the regression tests.

For the Boost.Function testsuite documentation, see:
  http://www.cs.rpi.edu/~gregod/Boost/ch02s05.html

The XML that generates the testsuite is quite simple. Here is the XML for
a test that already exists as a source file:

<testsuite name="function">
  <run filename="function_test.cpp">
    <purpose><para>Test the capabilities of the
<classname>boost::function</classname> class template.</para></purpose>
    <if-fails><para>The <classname>boost::function</classname> class
template may not be usable on your compiler. However, the library may
still be usable via the <classname>boost::functionN</classname> class
templates.</para></if-fails>
  </run>
</testsuite>

The testsuite name corresponds to the name of the library directory (e.g.,
'function', 'graph'). The "run" element creates a "run" testcase (could
also be "compile", "link", "compile-fail", "link-fail", or "run-fail")
with the given filename (in the directory libs/<libraryname>/test). The
"purpose" gives a short description of what the test checks, and the
"if-fails" tries to give the user an idea of the impact of a failing
testcase on his or her compiler/platform.

Here is a slightly more complex example, where the source for the testcase
is generated from code snippets in the XML:

  <run filename="function_ref_portable.cpp">
    <source>
<![CDATA[
#include <boost/function.hpp>
#include <iostream>
]]>

struct stateful_type { int operator(int) const { return 0; } };

int main()
{
  <snippet name="function.tutorial.ref.portable"/>
}
    </source>
    <purpose><para>Test <functionname>boost::ref</functionname> example
from tutorial.</para></purpose>
  </run>

The <source> element contains the source code to be placed in the file
libs/<library-name>/test/<filename>. The CDATA stuff allows one to type
C++ code directly (without escaping the '<' and '>' characters). The
<snippet> element pulls code from a <programlisting> element (with the
matching "name" attribute) and places it into the code. For reference, the
<programlisting> element that is found happens to look like this:

<programlisting conformance="portable"
name="function.tutorial.ref.portable">
  stateful_type a_function_object;
  <classname alt="functionN">boost::function1</classname>&lt;int, int&gt;
f;
  f = <functionname>boost::ref</functionname>(a_function_object);

  <classname alt="functionN">boost::function1</classname>&lt;int, int&gt;
f2(f);
</programlisting>

For the rest of the Function testsuite XML, look here:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/boost-sandbox/boost-sandbox/libs/documentation/examples/function/tests.xml?rev=1.1&content-type=text/vnd.viewcvs-markup

The generated Jamfile has been checked into Boost CVS as
boost/status/testsuites.jam and is included by boost/status/Jamfile.

Comments, questions, suggestions, and bug reports always welcome.

        Doug



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Boost-docs mailing list
[EMAIL PROTECTED]
Unsubscribe and other administrative requests: 
https://lists.sourceforge.net/lists/listinfo/boost-docs

Reply via email to