mirror of
https://github.com/catchorg/Catch2.git
synced 2025-02-17 03:43:29 +01:00
Fixed up CATCH_CONFIG_FAST_COMPILE for REQUIREs
Unexpected exceptions no longer cause abort and there should be no more potential for false negatives. The trade-off now is that exceptions are no longer translated.
This commit is contained in:
parent
3a3f152979
commit
95d85fb186
@ -38,6 +38,8 @@ namespace Catch {
|
|||||||
virtual std::string getCurrentTestName() const = 0;
|
virtual std::string getCurrentTestName() const = 0;
|
||||||
virtual const AssertionResult* getLastResult() const = 0;
|
virtual const AssertionResult* getLastResult() const = 0;
|
||||||
|
|
||||||
|
virtual void exceptionEarlyReported() = 0;
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +37,9 @@ namespace Catch {
|
|||||||
ResultBuilder::~ResultBuilder() {
|
ResultBuilder::~ResultBuilder() {
|
||||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||||
if ( m_guardException ) {
|
if ( m_guardException ) {
|
||||||
useActiveException( m_assertionInfo.resultDisposition );
|
m_stream.oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
|
||||||
|
captureResult( ResultWas::ThrewException );
|
||||||
|
getCurrentContext().getResultCapture()->exceptionEarlyReported();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@ namespace Catch {
|
|||||||
m_context( getCurrentMutableContext() ),
|
m_context( getCurrentMutableContext() ),
|
||||||
m_activeTestCase( CATCH_NULL ),
|
m_activeTestCase( CATCH_NULL ),
|
||||||
m_config( _config ),
|
m_config( _config ),
|
||||||
m_reporter( reporter )
|
m_reporter( reporter ),
|
||||||
|
m_shouldReportUnexpected ( true )
|
||||||
{
|
{
|
||||||
m_context.setRunner( this );
|
m_context.setRunner( this );
|
||||||
m_context.setConfig( m_config );
|
m_context.setConfig( m_config );
|
||||||
@ -223,6 +224,10 @@ namespace Catch {
|
|||||||
return &m_lastResult;
|
return &m_lastResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void exceptionEarlyReported() {
|
||||||
|
m_shouldReportUnexpected = false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition( std::string const& message ) {
|
virtual void handleFatalErrorCondition( std::string const& message ) {
|
||||||
// Don't rebuild the result -- the stringification itself can cause more fatal errors
|
// Don't rebuild the result -- the stringification itself can cause more fatal errors
|
||||||
// Instead, fake a result data.
|
// Instead, fake a result data.
|
||||||
@ -293,7 +298,13 @@ namespace Catch {
|
|||||||
// This just means the test was aborted due to failure
|
// This just means the test was aborted due to failure
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
makeUnexpectedResultBuilder().useActiveException();
|
// Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions
|
||||||
|
// are reported without translation at the point of origin.
|
||||||
|
#ifdef CATCH_CONFIG_FAST_COMPILE
|
||||||
|
if (m_shouldReportUnexpected) {
|
||||||
|
makeUnexpectedResultBuilder().useActiveException();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
m_testCaseTracker->close();
|
m_testCaseTracker->close();
|
||||||
handleUnfinishedSections();
|
handleUnfinishedSections();
|
||||||
@ -353,6 +364,7 @@ namespace Catch {
|
|||||||
std::vector<SectionEndInfo> m_unfinishedSections;
|
std::vector<SectionEndInfo> m_unfinishedSections;
|
||||||
std::vector<ITracker*> m_activeSections;
|
std::vector<ITracker*> m_activeSections;
|
||||||
TrackerContext m_trackerContext;
|
TrackerContext m_trackerContext;
|
||||||
|
bool m_shouldReportUnexpected;
|
||||||
};
|
};
|
||||||
|
|
||||||
IResultCapture& getResultCapture() {
|
IResultCapture& getResultCapture() {
|
||||||
|
Loading…
Reference in New Issue
Block a user