diff options
| author | Omer Ozarslan | 2019-02-01 09:11:30 -0600 |
|---|---|---|
| committer | Martin Hořeňovský | 2019-03-06 22:04:35 +0100 |
| commit | 99575b45db0ec0de2fb84b5e5cce7e93559387e5 (patch) | |
| tree | ecd6958cac5d8c7316c616587e8a8037dd8aabab /include/internal/catch_run_context.cpp | |
| parent | 1a03918455c1666808202a303342e6fff0c17c00 (diff) | |
| download | catch3-99575b45db0ec0de2fb84b5e5cce7e93559387e5.tar.gz | |
Add unscoped info functionality
This adds UNSCOPED_INFO macro, creating a log message that is stored
until the end of next assertion or the end of test case, whichever comes
first. These messages are not scoped locally, unlike messages created by
INFO macro.
Diffstat (limited to 'include/internal/catch_run_context.cpp')
| -rw-r--r-- | include/internal/catch_run_context.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp index c4defc9d..bc3a5151 100644 --- a/include/internal/catch_run_context.cpp +++ b/include/internal/catch_run_context.cpp @@ -161,6 +161,9 @@ namespace Catch { // and should be let to clear themselves out. static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); + if (result.getResultType() != ResultWas::Warning) + m_messageScopes.clear(); + // Reset working state resetAssertionInfo(); m_lastResult = result; @@ -215,6 +218,7 @@ namespace Catch { m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions)); m_messages.clear(); + m_messageScopes.clear(); } void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) { @@ -241,6 +245,10 @@ namespace Catch { m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end()); } + void RunContext::emplaceUnscopedMessage( MessageBuilder const& builder ) { + m_messageScopes.emplace_back( builder ); + } + std::string RunContext::getCurrentTestName() const { return m_activeTestCase ? m_activeTestCase->getTestCaseInfo().name @@ -301,6 +309,7 @@ namespace Catch { m_lastAssertionPassed = true; ++m_totals.assertions.passed; resetAssertionInfo(); + m_messageScopes.clear(); } bool RunContext::aborting() const { @@ -352,6 +361,7 @@ namespace Catch { m_testCaseTracker->close(); handleUnfinishedSections(); m_messages.clear(); + m_messageScopes.clear(); SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions); m_reporter->sectionEnded(testCaseSectionStats); |