Pass result disposition into RunContext::populateReaction directly

This avoids implicit dataflow through RunContext::m_lastAssertionInfo,
which will be useful in later refactoring.
This commit is contained in:
Martin Hořeňovský 2025-07-16 16:28:43 +02:00
parent 1b72e45354
commit 066f00acf5
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
2 changed files with 14 additions and 7 deletions

View File

@ -612,7 +612,8 @@ namespace Catch {
} }
else { else {
reportExpr(info, ResultWas::ExpressionFailed, &expr, negated ); reportExpr(info, ResultWas::ExpressionFailed, &expr, negated );
populateReaction( reaction ); populateReaction(
reaction, info.resultDisposition & ResultDisposition::Normal );
} }
resetAssertionInfo(); resetAssertionInfo();
} }
@ -647,7 +648,8 @@ namespace Catch {
const auto isOk = assertionResult.isOk(); const auto isOk = assertionResult.isOk();
assertionEnded( CATCH_MOVE(assertionResult) ); assertionEnded( CATCH_MOVE(assertionResult) );
if ( !isOk ) { if ( !isOk ) {
populateReaction( reaction ); populateReaction(
reaction, info.resultDisposition & ResultDisposition::Normal );
} else if ( resultType == ResultWas::ExplicitSkip ) { } else if ( resultType == ResultWas::ExplicitSkip ) {
// TODO: Need to handle this explicitly, as ExplicitSkip is // TODO: Need to handle this explicitly, as ExplicitSkip is
// considered "OK" // considered "OK"
@ -673,13 +675,15 @@ namespace Catch {
data.message = CATCH_MOVE(message); data.message = CATCH_MOVE(message);
AssertionResult assertionResult{ info, CATCH_MOVE(data) }; AssertionResult assertionResult{ info, CATCH_MOVE(data) };
assertionEnded( CATCH_MOVE(assertionResult) ); assertionEnded( CATCH_MOVE(assertionResult) );
populateReaction( reaction ); populateReaction( reaction,
info.resultDisposition & ResultDisposition::Normal );
resetAssertionInfo(); resetAssertionInfo();
} }
void RunContext::populateReaction( AssertionReaction& reaction ) { void RunContext::populateReaction( AssertionReaction& reaction,
bool has_normal_disposition ) {
reaction.shouldDebugBreak = m_shouldDebugBreak; reaction.shouldDebugBreak = m_shouldDebugBreak;
reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal); reaction.shouldThrow = aborting() || has_normal_disposition;
} }
void RunContext::handleIncomplete( void RunContext::handleIncomplete(
@ -706,7 +710,10 @@ namespace Catch {
const auto isOk = assertionResult.isOk(); const auto isOk = assertionResult.isOk();
assertionEnded( CATCH_MOVE(assertionResult) ); assertionEnded( CATCH_MOVE(assertionResult) );
if ( !isOk ) { populateReaction( reaction ); } if ( !isOk ) {
populateReaction(
reaction, info.resultDisposition & ResultDisposition::Normal );
}
resetAssertionInfo(); resetAssertionInfo();
} }

View File

@ -129,7 +129,7 @@ namespace Catch {
ITransientExpression const *expr, ITransientExpression const *expr,
bool negated ); bool negated );
void populateReaction( AssertionReaction& reaction ); void populateReaction( AssertionReaction& reaction, bool has_normal_disposition );
private: private: