mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Fixed section ordering issue
If a branch section completes without running any inner sections it will no run subsequent sections (until the next isolated run).
This commit is contained in:
@@ -96,26 +96,33 @@ TEST_CASE( "Sections/nested3", "nested SECTION tests" )
|
||||
|
||||
runner.runMatching( "./Sections/nested/a/b", "mock" );
|
||||
CHECK( runner.getLog() ==
|
||||
"[tc]( ./Sections/nested/a/b ){ "
|
||||
|
||||
"[g]( test case run ){ "
|
||||
"[s]( c ){ "
|
||||
"[s]( d (leaf) ){ } [s]( d (leaf) ) "
|
||||
"} [s]( c ) "
|
||||
"} [g]( test case run )"
|
||||
|
||||
"[g]( test case run ){ "
|
||||
"[s]( c ){ "
|
||||
"[s]( e (leaf) ){ } [s]( e (leaf) ) "
|
||||
"} [s]( c ) "
|
||||
"} [g]( test case run )"
|
||||
|
||||
"[g]( test case run ){ "
|
||||
"[s]( c ){ } [s]( c ) "
|
||||
"[s]( f (leaf) ){ } [s]( f (leaf) ) "
|
||||
"} [g]( test case run ) "
|
||||
|
||||
"} [tc]( ./Sections/nested/a/b )" );
|
||||
"\\[tc] ./Sections/nested/a/b\n"
|
||||
|
||||
" \\[g] test case run\n"
|
||||
" \\ [s] c\n"
|
||||
" \\ [s] d (leaf)\n"
|
||||
" / [s] d (leaf)\n"
|
||||
" / [s] c\n"
|
||||
" /[g] test case run\n"
|
||||
|
||||
" \\[g] test case run\n"
|
||||
" \\ [s] c\n"
|
||||
" \\ [s] e (leaf)\n"
|
||||
" / [s] e (leaf)\n"
|
||||
" / [s] c\n"
|
||||
" /[g] test case run\n"
|
||||
|
||||
" \\[g] test case run\n"
|
||||
" \\ [s] c\n"
|
||||
" / [s] c\n"
|
||||
" /[g] test case run\n"
|
||||
|
||||
" \\[g] test case run\n"
|
||||
" \\ [s] f (leaf)\n"
|
||||
" / [s] f (leaf)\n"
|
||||
" /[g] test case run\n"
|
||||
|
||||
"/[tc] ./Sections/nested/a/b\n" );
|
||||
|
||||
}
|
||||
|
||||
|
@@ -95,8 +95,7 @@ namespace Catch
|
||||
const std::string& groupName
|
||||
)
|
||||
{
|
||||
if( shouldRecord( recordGroups ) )
|
||||
m_log << recordGroups << "( " << groupName << " ){ ";
|
||||
openLabel( recordGroups, groupName );
|
||||
}
|
||||
|
||||
virtual void EndGroup
|
||||
@@ -105,8 +104,7 @@ namespace Catch
|
||||
const Totals& totals
|
||||
)
|
||||
{
|
||||
if( shouldRecord( recordGroups ) )
|
||||
m_log << " } " << recordGroups << "( " << groupName << " )";
|
||||
closeLabel( recordGroups, groupName );
|
||||
}
|
||||
|
||||
virtual void StartSection
|
||||
@@ -115,8 +113,7 @@ namespace Catch
|
||||
const std::string description
|
||||
)
|
||||
{
|
||||
if( shouldRecord( recordSections ) )
|
||||
m_log << recordSections << "( " << sectionName << " ){ ";
|
||||
openLabel( recordSections, sectionName );
|
||||
}
|
||||
|
||||
virtual void EndSection
|
||||
@@ -125,8 +122,7 @@ namespace Catch
|
||||
const Counts& assertions
|
||||
)
|
||||
{
|
||||
if( shouldRecord( recordSections ) )
|
||||
m_log << " } " << recordSections << "( " << sectionName << " )";
|
||||
closeLabel( recordSections, sectionName );
|
||||
}
|
||||
|
||||
virtual void StartTestCase
|
||||
@@ -134,8 +130,7 @@ namespace Catch
|
||||
const TestCaseInfo& testInfo
|
||||
)
|
||||
{
|
||||
if( shouldRecord( recordTestCases ) )
|
||||
m_log << recordTestCases << "( " << testInfo.getName() << " ){ ";
|
||||
openLabel( recordTestCases, testInfo.getName() );
|
||||
}
|
||||
|
||||
virtual void EndTestCase
|
||||
@@ -146,8 +141,7 @@ namespace Catch
|
||||
const std::string& stdErr
|
||||
)
|
||||
{
|
||||
if( shouldRecord( recordTestCases ) )
|
||||
m_log << " } " << recordTestCases << "( " << testInfo.getName() << " )";
|
||||
closeLabel( recordTestCases, testInfo.getName() );
|
||||
}
|
||||
|
||||
virtual void Result
|
||||
@@ -214,6 +208,32 @@ namespace Catch
|
||||
{
|
||||
return m_recorders.find( recorder ) != m_recorders.end();
|
||||
}
|
||||
|
||||
void openLabel( const std::string& label, const std::string& arg = "" )
|
||||
{
|
||||
if( shouldRecord( label ) )
|
||||
{
|
||||
m_log << m_indent << "\\" << label;
|
||||
if( !arg.empty() )
|
||||
m_log << " " << arg;
|
||||
m_log << "\n";
|
||||
m_indent += " ";
|
||||
}
|
||||
}
|
||||
|
||||
void closeLabel( const std::string& label, const std::string& arg = "" )
|
||||
{
|
||||
if( shouldRecord( label ) )
|
||||
{
|
||||
m_indent = m_indent.substr( 0, m_indent.size()-1 );
|
||||
m_log << m_indent << "/" << label;
|
||||
if( !arg.empty() )
|
||||
m_log << " " << arg;
|
||||
m_log << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
std::string m_indent;
|
||||
std::ostringstream m_log;
|
||||
std::set<std::string> m_recorders;
|
||||
};
|
||||
|
Reference in New Issue
Block a user