diff options
| author | Phil Nash | 2015-09-26 18:12:21 -0700 |
|---|---|---|
| committer | Phil Nash | 2015-09-26 18:12:21 -0700 |
| commit | 166ca2e81901c2a12e10fcbf60908df286c2caed (patch) | |
| tree | f48019aa8f7e000794222404ae839cfe67ca9fea /include/internal/catch_run_context.hpp | |
| parent | d234ed1a67a41e2d14ddb1fbe839a4e5ab466311 (diff) | |
| download | catch3-166ca2e81901c2a12e10fcbf60908df286c2caed.tar.gz | |
Do uncaught_exception checking before calling sectionEnded
- split the uncaught handling (adding to unfinishedSections) into separate method
Diffstat (limited to 'include/internal/catch_run_context.hpp')
| -rw-r--r-- | include/internal/catch_run_context.hpp | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/include/internal/catch_run_context.hpp b/include/internal/catch_run_context.hpp index 39b9888b..3ec12af6 100644 --- a/include/internal/catch_run_context.hpp +++ b/include/internal/catch_run_context.hpp @@ -176,22 +176,21 @@ namespace Catch { assertions.failed++; return true; } - - virtual void sectionEnded( SectionInfo const& info, Counts const& prevAssertions, double _durationInSeconds ) { - if( std::uncaught_exception() ) { - m_unfinishedSections.push_back( UnfinishedSections( info, prevAssertions, _durationInSeconds ) ); - return; - } - - Counts assertions = m_totals.assertions - prevAssertions; + + virtual void sectionEnded( SectionEndInfo const& endInfo ) { + Counts assertions = m_totals.assertions - endInfo.prevAssertions; bool missingAssertions = testForMissingAssertions( assertions ); - + m_testCaseTracker->leaveSection(); - - m_reporter->sectionEnded( SectionStats( info, assertions, _durationInSeconds, missingAssertions ) ); + + m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) ); m_messages.clear(); } + virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) { + m_unfinishedSections.push_back( endInfo ); + } + virtual void pushScopedMessage( MessageInfo const& message ) { m_messages.push_back( message ); } @@ -309,28 +308,18 @@ namespace Catch { m_lastAssertionInfo.capturedExpression.c_str(), m_lastAssertionInfo.resultDisposition ); } - + void handleUnfinishedSections() { // 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_reverse_iterator it = m_unfinishedSections.rbegin(), + for( std::vector<SectionEndInfo>::const_reverse_iterator it = m_unfinishedSections.rbegin(), itEnd = m_unfinishedSections.rend(); it != itEnd; ++it ) - sectionEnded( it->info, it->prevAssertions, it->durationInSeconds ); + sectionEnded( *it ); m_unfinishedSections.clear(); } - struct UnfinishedSections { - UnfinishedSections( SectionInfo const& _info, Counts const& _prevAssertions, double _durationInSeconds ) - : info( _info ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds ) - {} - - SectionInfo info; - Counts prevAssertions; - double durationInSeconds; - }; - TestRunInfo m_runInfo; IMutableContext& m_context; TestCase const* m_activeTestCase; @@ -345,7 +334,7 @@ namespace Catch { IResultCapture* m_prevResultCapture; Ptr<IConfig const> m_prevConfig; AssertionInfo m_lastAssertionInfo; - std::vector<UnfinishedSections> m_unfinishedSections; + std::vector<SectionEndInfo> m_unfinishedSections; }; IResultCapture& getResultCapture() { |