Cache config::abortAfter and config::shouldDebugBreak in RunContext

This commit is contained in:
Martin Hořeňovský 2025-07-16 19:23:51 +02:00
parent f7968e9697
commit 1b72e45354
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
2 changed files with 7 additions and 3 deletions

View File

@ -171,7 +171,9 @@ namespace Catch {
m_reporter(CATCH_MOVE(reporter)), m_reporter(CATCH_MOVE(reporter)),
m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal },
m_outputRedirect( makeOutputRedirect( m_reporter->getPreferences().shouldRedirectStdOut ) ), m_outputRedirect( makeOutputRedirect( m_reporter->getPreferences().shouldRedirectStdOut ) ),
m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) m_abortAfterXFailedAssertions( m_config->abortAfter() ),
m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ),
m_shouldDebugBreak( m_config->shouldDebugBreak() )
{ {
getCurrentMutableContext().setResultCapture( this ); getCurrentMutableContext().setResultCapture( this );
m_reporter->testRunStarting(m_runInfo); m_reporter->testRunStarting(m_runInfo);
@ -523,7 +525,7 @@ namespace Catch {
} }
bool RunContext::aborting() const { bool RunContext::aborting() const {
return m_totals.assertions.failed >= static_cast<std::size_t>(m_config->abortAfter()); return m_totals.assertions.failed >= m_abortAfterXFailedAssertions;
} }
void RunContext::runCurrentTest() { void RunContext::runCurrentTest() {
@ -676,7 +678,7 @@ namespace Catch {
} }
void RunContext::populateReaction( AssertionReaction& reaction ) { void RunContext::populateReaction( AssertionReaction& reaction ) {
reaction.shouldDebugBreak = m_config->shouldDebugBreak(); reaction.shouldDebugBreak = m_shouldDebugBreak;
reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal); reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal);
} }

View File

@ -151,9 +151,11 @@ namespace Catch {
TrackerContext m_trackerContext; TrackerContext m_trackerContext;
Detail::unique_ptr<OutputRedirect> m_outputRedirect; Detail::unique_ptr<OutputRedirect> m_outputRedirect;
FatalConditionHandler m_fatalConditionhandler; FatalConditionHandler m_fatalConditionhandler;
size_t m_abortAfterXFailedAssertions;
bool m_lastAssertionPassed = false; bool m_lastAssertionPassed = false;
bool m_shouldReportUnexpected = true; bool m_shouldReportUnexpected = true;
bool m_includeSuccessfulResults; bool m_includeSuccessfulResults;
bool m_shouldDebugBreak;
}; };
void seedRng(IConfig const& config); void seedRng(IConfig const& config);