mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
XML Reporter closes tag and flushes stream at end of TestCase and Section tags.
This fixes an issue where XML reports on stdout are broken by printf statements
This commit is contained in:
parent
bc68b9f454
commit
873ef276b6
@ -211,6 +211,13 @@ namespace Catch {
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ensureTagClosed() {
|
||||
if( m_tagIsOpen ) {
|
||||
m_os << ">" << std::endl;
|
||||
m_tagIsOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
XmlWriter( XmlWriter const& );
|
||||
void operator=( XmlWriter const& );
|
||||
@ -219,13 +226,6 @@ namespace Catch {
|
||||
m_os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
||||
}
|
||||
|
||||
void ensureTagClosed() {
|
||||
if( m_tagIsOpen ) {
|
||||
m_os << ">" << std::endl;
|
||||
m_tagIsOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
void newlineIfNecessary() {
|
||||
if( m_needsNewline ) {
|
||||
m_os << std::endl;
|
||||
|
@ -67,6 +67,7 @@ namespace Catch {
|
||||
|
||||
if ( m_config->showDurations() == ShowDurations::Always )
|
||||
m_testCaseTimer.start();
|
||||
m_xml.ensureTagClosed();
|
||||
}
|
||||
|
||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||
@ -75,6 +76,7 @@ namespace Catch {
|
||||
m_xml.startElement( "Section" )
|
||||
.writeAttribute( "name", trim( sectionInfo.name ) )
|
||||
.writeAttribute( "description", sectionInfo.description );
|
||||
m_xml.ensureTagClosed();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ MiscTests.cpp:<line number>: FAILED:
|
||||
with expansion:
|
||||
false
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
spanner-------------------------------------------------------------------------------
|
||||
just failure
|
||||
-------------------------------------------------------------------------------
|
||||
MessageTests.cpp:<line number>
|
||||
@ -829,6 +829,6 @@ with expansion:
|
||||
"first" == "second"
|
||||
|
||||
===============================================================================
|
||||
test cases: 160 | 116 passed | 42 failed | 2 failed as expected
|
||||
test cases: 161 | 117 passed | 42 failed | 2 failed as expected
|
||||
assertions: 932 | 836 passed | 78 failed | 18 failed as expected
|
||||
|
||||
|
@ -8329,7 +8329,7 @@ MiscTests.cpp:<line number>
|
||||
MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
spanner-------------------------------------------------------------------------------
|
||||
just failure
|
||||
-------------------------------------------------------------------------------
|
||||
MessageTests.cpp:<line number>
|
||||
@ -9164,6 +9164,6 @@ MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 160 | 115 passed | 43 failed | 2 failed as expected
|
||||
test cases: 161 | 116 passed | 43 failed | 2 failed as expected
|
||||
assertions: 934 | 836 passed | 80 failed | 18 failed as expected
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuites>
|
||||
<testsuitesspanner>
|
||||
<testsuite name="<exe-name>" errors="13" failures="68" tests="935" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
|
||||
<testcase classname="global" name="#542" time="{duration}"/>
|
||||
|
@ -8845,6 +8845,9 @@ there"
|
||||
<TestCase name="first tag" tags="[tag1]">
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="has printf">
|
||||
spanner <OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="just failure" tags="[.][fail][hide][isolated info][messages]">
|
||||
<Failure>
|
||||
Previous info should not be seen
|
||||
|
@ -399,3 +399,9 @@ TEST_CASE( "X/level/0/a", "[Tricky]" ) { SUCCEED(""); }
|
||||
TEST_CASE( "X/level/0/b", "[Tricky][fizz]" ){ SUCCEED(""); }
|
||||
TEST_CASE( "X/level/1/a", "[Tricky]" ) { SUCCEED(""); }
|
||||
TEST_CASE( "X/level/1/b", "[Tricky]" ) { SUCCEED(""); }
|
||||
|
||||
TEST_CASE( "has printf", "" ) {
|
||||
|
||||
// This can cause problems as, currently, stdout itself is not redirect - only the cout (and cerr) buffer
|
||||
printf( "spanner" );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user