mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Removed deprecated section tracking implementation and tests
This commit is contained in:
		| @@ -105,7 +105,7 @@ namespace Catch { | ||||
|                 } | ||||
|                 while( !m_testCaseTracker->isSuccessfullyCompleted() && !aborting() ); | ||||
|             } | ||||
|             // !TBD: deprecated | ||||
|             // !TBD: deprecated - this will be replaced by indexed trackers | ||||
|             while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() ); | ||||
|  | ||||
|             Totals deltaTotals = m_totals.delta( prevTotals ); | ||||
| @@ -266,7 +266,6 @@ namespace Catch { | ||||
|             double duration = 0; | ||||
|             try { | ||||
|                 m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal ); | ||||
| //                TestCaseTracker::Guard guard( *m_testCaseTracker ); | ||||
|  | ||||
|                 seedRng( *m_config ); | ||||
|                  | ||||
| @@ -284,11 +283,9 @@ namespace Catch { | ||||
|             } | ||||
|             catch( TestFailureException& ) { | ||||
|                 // This just means the test was aborted due to failure | ||||
| //                m_testCaseTracker->fail(); | ||||
|             } | ||||
|             catch(...) { | ||||
|                 makeUnexpectedResultBuilder().useActiveException(); | ||||
| //                m_testCaseTracker->fail(); | ||||
|             } | ||||
|             m_testCaseTracker->close(); | ||||
|             handleUnfinishedSections(); | ||||
|   | ||||
| @@ -310,138 +310,6 @@ using TestCaseTracking::ITracker; | ||||
| using TestCaseTracking::TrackerContext; | ||||
| using TestCaseTracking::SectionTracker; | ||||
| using TestCaseTracking::IndexTracker; | ||||
|      | ||||
| // !TBD: Deprecated | ||||
| namespace SectionTracking { | ||||
|  | ||||
|      | ||||
|     class TrackedSection { | ||||
|          | ||||
|         typedef std::map<std::string, TrackedSection> TrackedSections; | ||||
|          | ||||
|     public: | ||||
|         enum RunState { | ||||
|             NotStarted, | ||||
|             Executing, | ||||
|             ExecutingChildren, | ||||
|             Completed | ||||
|         }; | ||||
|          | ||||
|         TrackedSection( std::string const& name, TrackedSection* parent ) | ||||
|         :   m_name( name ), m_runState( NotStarted ), m_parent( parent ) | ||||
|         {} | ||||
|          | ||||
|         RunState runState() const { return m_runState; } | ||||
|          | ||||
|         TrackedSection* findChild( std::string const& childName ); | ||||
|         TrackedSection* acquireChild( std::string const& childName ); | ||||
|  | ||||
|         void enter() { | ||||
|             if( m_runState == NotStarted ) | ||||
|                 m_runState = Executing; | ||||
|         } | ||||
|         void leave(); | ||||
|  | ||||
|         TrackedSection* getParent() { | ||||
|             return m_parent; | ||||
|         } | ||||
|         bool hasChildren() const { | ||||
|             return !m_children.empty(); | ||||
|         } | ||||
|          | ||||
|     private: | ||||
|         std::string m_name; | ||||
|         RunState m_runState; | ||||
|         TrackedSections m_children; | ||||
|         TrackedSection* m_parent;         | ||||
|     }; | ||||
|      | ||||
|     inline TrackedSection* TrackedSection::findChild( std::string const& childName ) { | ||||
|         TrackedSections::iterator it = m_children.find( childName ); | ||||
|         return it != m_children.end() | ||||
|             ? &it->second | ||||
|             : CATCH_NULL; | ||||
|     } | ||||
|     inline TrackedSection* 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 ); | ||||
|     } | ||||
|     inline void TrackedSection::leave() { | ||||
|         for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end(); | ||||
|                 it != itEnd; | ||||
|                 ++it ) | ||||
|             if( it->second.runState() != Completed ) { | ||||
|                 m_runState = ExecutingChildren; | ||||
|                 return; | ||||
|             } | ||||
|         m_runState = Completed; | ||||
|     } | ||||
|  | ||||
|     class TestCaseTracker { | ||||
|     public: | ||||
|         TestCaseTracker( std::string const& testCaseName ) | ||||
|         :   m_testCase( testCaseName, CATCH_NULL ), | ||||
|             m_currentSection( &m_testCase ), | ||||
|             m_completedASectionThisRun( false ) | ||||
|         {} | ||||
|  | ||||
|         bool enterSection( std::string const& name ) { | ||||
|             TrackedSection* child = m_currentSection->acquireChild( name ); | ||||
|             if( m_completedASectionThisRun || child->runState() == TrackedSection::Completed ) | ||||
|                 return false; | ||||
|  | ||||
|             m_currentSection = child; | ||||
|             m_currentSection->enter(); | ||||
|             return true; | ||||
|         } | ||||
|         void leaveSection() { | ||||
|             m_currentSection->leave(); | ||||
|             m_currentSection = m_currentSection->getParent(); | ||||
|             assert( m_currentSection != CATCH_NULL ); | ||||
|             m_completedASectionThisRun = true; | ||||
|         } | ||||
|  | ||||
|         bool currentSectionHasChildren() const { | ||||
|             return m_currentSection->hasChildren(); | ||||
|         } | ||||
|         bool isCompleted() const { | ||||
|             return m_testCase.runState() == TrackedSection::Completed; | ||||
|         } | ||||
|  | ||||
|         class Guard { | ||||
|         public: | ||||
|             Guard( TestCaseTracker& tracker ) : m_tracker( tracker ) { | ||||
|                 m_tracker.enterTestCase(); | ||||
|             } | ||||
|             ~Guard() { | ||||
|                 m_tracker.leaveTestCase(); | ||||
|             } | ||||
|         private: | ||||
|             Guard( Guard const& ); | ||||
|             void operator = ( Guard const& ); | ||||
|             TestCaseTracker& m_tracker; | ||||
|         }; | ||||
|  | ||||
|     private: | ||||
|         void enterTestCase() { | ||||
|             m_currentSection = &m_testCase; | ||||
|             m_completedASectionThisRun = false; | ||||
|             m_testCase.enter(); | ||||
|         } | ||||
|         void leaveTestCase() { | ||||
|             m_testCase.leave(); | ||||
|         } | ||||
|  | ||||
|         TrackedSection m_testCase; | ||||
|         TrackedSection* m_currentSection; | ||||
|         bool m_completedASectionThisRun; | ||||
|     }; | ||||
|  | ||||
| } // namespace SectionTracking | ||||
|  | ||||
| using SectionTracking::TestCaseTracker; | ||||
|  | ||||
| } // namespace Catch | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash