Boost logo

Boost Users :

From: Kim Barrett (kab_at_[hidden])
Date: 2005-08-19 13:35:55

I'm using the unit test framework provided by Boost.Test, mostly
using the auto unit test facility. I wrote a parser for the XML
formatted report output, as part of a regression package.
Unfortunately, changes between 1.32 and 1.33 are causing a problem.

The format of the XML output changed quite a bit between 1.32 and
1.33. Ok, I can deal with that; in fact, the new format is quite a
bit easier to deal with, and I've already finished with the changes.
It would be nice if this format were documented though.

Unfortunately, there is one change that I haven't been able to figure
out a good way to deal with. If a test case aborts, due to an
exception uncaught by the test itself, the exception is caught by the
unit test framework. The occurrence of the abort is recorded in the
test results. In 1.32, this would be reported by including an
<aborted ...> subentry for the test case data, including some
descriptive text. In 1.33, the descriptive text is printed to
std::cerr and the report indicates that the test case was aborted via
the "result" value for the test case. The generated report no longer
contains the descriptive text. (I don't care all that much about this
last change.)

The problem is the printing of the descriptive text for the exception
to std::cerr. That is also the stream to which the test report is
written, and I'm capturing the report information by redirecting
stderr to a file when invoking a test program. The exception text
ends up appearing at the beginning of the report file, and isn't
valid XML, which causes my report parser to die. (If necessary, I may
end up prefixing the parser with a step to skip over anything that
doesn't look like XML, but that's pretty ugly.)

Now, I never really liked redirecting stderr to a file in order to
capture the report. What if something in the test program were to
write to stderr? (Which is exactly what is happening now.) I see that
there is now (in 1.33) a mechanism for setting the stream used by the
report generator (boost:unit_test::results_reporter::set_stream()).
But after spending the last couple of days pouring over the
documentation and sources for Boost.Test, I have no idea where I
would put a call to that function that doesn't involve patching the
Boost.Test sources. There doesn't seem to be a place to insert such
user code, at least not that I can find. Have I overlooked something,
or is this really a hole in the present design / implementation?

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at