Skip to content

Commit 895d601

Browse files
committed
Cache config::abortAfter and config::shouldDebugBreak in RunContext
1 parent 1a7fef9 commit 895d601

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/catch2/internal/catch_run_context.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ namespace Catch {
171171
m_reporter(CATCH_MOVE(reporter)),
172172
m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal },
173173
m_outputRedirect( makeOutputRedirect( m_reporter->getPreferences().shouldRedirectStdOut ) ),
174-
m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions )
174+
m_abortAfterXFailedAssertions( m_config->abortAfter() ),
175+
m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ),
176+
m_shouldDebugBreak( m_config->shouldDebugBreak() )
175177
{
176178
getCurrentMutableContext().setResultCapture( this );
177179
m_reporter->testRunStarting(m_runInfo);
@@ -522,7 +524,7 @@ namespace Catch {
522524
}
523525

524526
bool RunContext::aborting() const {
525-
return m_totals.assertions.failed >= static_cast<std::size_t>(m_config->abortAfter());
527+
return m_totals.assertions.failed >= m_abortAfterXFailedAssertions;
526528
}
527529

528530
void RunContext::runCurrentTest() {
@@ -679,7 +681,7 @@ namespace Catch {
679681

680682
void RunContext::populateReaction( AssertionReaction& reaction,
681683
bool has_normal_disposition ) {
682-
reaction.shouldDebugBreak = m_config->shouldDebugBreak();
684+
reaction.shouldDebugBreak = m_shouldDebugBreak;
683685
reaction.shouldThrow = aborting() || has_normal_disposition;
684686
}
685687

src/catch2/internal/catch_run_context.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@ namespace Catch {
151151
TrackerContext m_trackerContext;
152152
Detail::unique_ptr<OutputRedirect> m_outputRedirect;
153153
FatalConditionHandler m_fatalConditionhandler;
154+
size_t m_abortAfterXFailedAssertions;
154155
bool m_lastAssertionPassed = false;
155156
bool m_shouldReportUnexpected = true;
156157
bool m_includeSuccessfulResults;
158+
bool m_shouldDebugBreak;
157159
};
158160

159161
void seedRng(IConfig const& config);

0 commit comments

Comments
 (0)