mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Sections are, once again, eagerly entered.
When the section tracking code was rewritten a while back to simplify and iron out some bugs the order of evaluation was changed so that each new section was skipped on the first run through. This had unwelcome consequences for some people. This commit restores the original semantics (while maintaining the simpler, less buggy, new code).
This commit is contained in:
@@ -271,8 +271,8 @@ namespace Catch {
|
||||
}
|
||||
// If sections ended prematurely due to an exception we stored their
|
||||
// infos here so we can tear them down outside the unwind process.
|
||||
for( std::vector<UnfinishedSections>::const_iterator it = m_unfinishedSections.begin(),
|
||||
itEnd = m_unfinishedSections.end();
|
||||
for( std::vector<UnfinishedSections>::const_reverse_iterator it = m_unfinishedSections.rbegin(),
|
||||
itEnd = m_unfinishedSections.rend();
|
||||
it != itEnd;
|
||||
++it )
|
||||
sectionEnded( it->info, it->prevAssertions, it->durationInSeconds );
|
||||
|
@@ -33,13 +33,18 @@ namespace SectionTracking {
|
||||
|
||||
RunState runState() const { return m_runState; }
|
||||
|
||||
void addChild( std::string const& childName ) {
|
||||
TrackedSection* findChild( std::string const& childName ) {
|
||||
TrackedSections::iterator it = m_children.find( childName );
|
||||
return it != m_children.end()
|
||||
? &it->second
|
||||
: NULL;
|
||||
}
|
||||
TrackedSection* acquireChild( std::string const& childName ) {
|
||||
if( TrackedSection* child = findChild( childName ) )
|
||||
return child;
|
||||
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
|
||||
return findChild( childName );
|
||||
}
|
||||
TrackedSection* getChild( std::string const& childName ) {
|
||||
return &m_children.find( childName )->second;
|
||||
}
|
||||
|
||||
void enter() {
|
||||
if( m_runState == NotStarted )
|
||||
m_runState = Executing;
|
||||
@@ -78,21 +83,13 @@ namespace SectionTracking {
|
||||
{}
|
||||
|
||||
bool enterSection( std::string const& name ) {
|
||||
if( m_completedASectionThisRun )
|
||||
TrackedSection* child = m_currentSection->acquireChild( name );
|
||||
if( m_completedASectionThisRun || child->runState() == TrackedSection::Completed )
|
||||
return false;
|
||||
if( m_currentSection->runState() == TrackedSection::Executing ) {
|
||||
m_currentSection->addChild( name );
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
TrackedSection* child = m_currentSection->getChild( name );
|
||||
if( child->runState() != TrackedSection::Completed ) {
|
||||
m_currentSection = child;
|
||||
m_currentSection->enter();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_currentSection = child;
|
||||
m_currentSection->enter();
|
||||
return true;
|
||||
}
|
||||
void leaveSection() {
|
||||
m_currentSection->leave();
|
||||
@@ -110,9 +107,7 @@ namespace SectionTracking {
|
||||
|
||||
class Guard {
|
||||
public:
|
||||
Guard( TestCaseTracker& tracker )
|
||||
: m_tracker( tracker )
|
||||
{
|
||||
Guard( TestCaseTracker& tracker ) : m_tracker( tracker ) {
|
||||
m_tracker.enterTestCase();
|
||||
}
|
||||
~Guard() {
|
||||
|
@@ -13,7 +13,7 @@
|
||||
namespace Catch {
|
||||
|
||||
// These numbers are maintained by a script
|
||||
Version libraryVersion( 1, 0, 38, "master" );
|
||||
Version libraryVersion( 1, 0, 39, "master" );
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||
|
Reference in New Issue
Block a user