Opened 6 years ago
Last modified 6 years ago
#12452 new Bugs
XML log can contain unescaped characters from test output
Reported by: | Owned by: | Gennadiy Rozental | |
---|---|---|---|
Milestone: | To Be Determined | Component: | test |
Version: | Boost 1.61.0 | Severity: | Problem |
Keywords: | XML | Cc: |
Description
XML log format does not escape user test output, so the resulting XML file is not valid, e.g.
BOOST_AUTO_TEST_CASE(test) { std::cout << "&"; }
This issue makes it impossible to parse the output with standard XML parsers.
A file log sink can be used to separate Boost.Test output from user output. Unfortunately, the XML reporter does not flush the output stream, so if a unit test runner wants to show test results as soon as they are available, the stderr sink is the only option.
For comparison, the Catch unit test framework redirects cout and cerr and later prints escaped output inside a corresponding XML node.
Change History (2)
follow-up: 2 comment:1 by , 6 years ago
comment:2 by , 6 years ago
I'm the author of the unit test runner in ReSharper C++, so I'm actually providing an interface to Boost.Test.
We can't use XML log format with Google Test, since it's not streaming, so we use the console reporter which is fairly easy to parse. In Boost.Test the XML reporter is streaming, but not flushing, so we use it with the stderr sink - the only problem is unescaped user output which the standard XML reader fails to parse, and we've got several user requests about this problem.
Again, please take a look at how Catch handles that - it intercepts all user output and escapes it (e.g. in the JUnit reporter). Ideally I'd like Boost.Test to adopt the same approach.
If you want to have that output in the final XML, I suggest you using
BOOST_TEST_MESSAGE
instead (see documentation here).This is also what eg. Google test proposes.
In any case, if you mess with the logger output stream, then the output stream is likely to be invalid.