mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Fixed line/no regression for SECTIONs
Unexpected exceptions within a section now get the SECTION's line no. again (instead of TEST_CASE line/no)
This commit is contained in:
parent
78fba28c4b
commit
b323fc7e6c
@ -174,13 +174,11 @@ namespace Catch {
|
|||||||
oss << name << "@" << lineInfo;
|
oss << name << "@" << lineInfo;
|
||||||
|
|
||||||
|
|
||||||
m_assertionInfoStack.push_back( m_lastAssertionInfo );
|
|
||||||
m_lastAssertionInfo = AssertionInfo( "SECTION", lineInfo );
|
|
||||||
|
|
||||||
|
|
||||||
if( !m_runningTest->addSection( oss.str() ) )
|
if( !m_runningTest->addSection( oss.str() ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
m_lastAssertionInfo.lineInfo = lineInfo;
|
||||||
|
|
||||||
m_reporter->StartSection( name, description );
|
m_reporter->StartSection( name, description );
|
||||||
assertions = m_totals.assertions;
|
assertions = m_totals.assertions;
|
||||||
|
|
||||||
@ -198,8 +196,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
m_runningTest->endSection( name );
|
m_runningTest->endSection( name );
|
||||||
m_reporter->EndSection( name, assertions );
|
m_reporter->EndSection( name, assertions );
|
||||||
m_lastAssertionInfo = m_assertionInfoStack.back();
|
|
||||||
m_assertionInfoStack.pop_back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
|
virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
|
||||||
@ -296,7 +292,6 @@ namespace Catch {
|
|||||||
IResultCapture* m_prevResultCapture;
|
IResultCapture* m_prevResultCapture;
|
||||||
const IConfig* m_prevConfig;
|
const IConfig* m_prevConfig;
|
||||||
AssertionInfo m_lastAssertionInfo;
|
AssertionInfo m_lastAssertionInfo;
|
||||||
std::vector<AssertionInfo> m_assertionInfoStack;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@ -151,7 +151,7 @@ TEST_CASE( "./succeeding/exceptions/error messages", "The error messages produce
|
|||||||
INFO( runner.getLog() );
|
INFO( runner.getLog() );
|
||||||
// CHECK( runner.getLog().find( "Unexpected exception" ) != std::string::npos ); // Mock reporter doesn't say this
|
// CHECK( runner.getLog().find( "Unexpected exception" ) != std::string::npos ); // Mock reporter doesn't say this
|
||||||
CHECK_THAT( runner.getLog(), Contains( "Exception from section" ) );
|
CHECK_THAT( runner.getLog(), Contains( "Exception from section" ) );
|
||||||
// CHECK( runner.getLog().find( CATCH_GET_LINE_INFO( "the section2" ) ) != std::string::npos ); // Mock reporter doesn't say this
|
CHECK_THAT( runner.getLog(), Contains( CATCH_GET_LINE_INFO( "the section2" ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results"
|
|||||||
SECTION( "selftest/test counts/succeeding tests",
|
SECTION( "selftest/test counts/succeeding tests",
|
||||||
"Number of 'succeeding' tests is fixed" ) {
|
"Number of 'succeeding' tests is fixed" ) {
|
||||||
Totals totals = runner.runMatching( "./succeeding/*" );
|
Totals totals = runner.runMatching( "./succeeding/*" );
|
||||||
CHECK( totals.assertions.passed == 288 );
|
CHECK( totals.assertions.passed == 289 );
|
||||||
CHECK( totals.assertions.failed == 0 );
|
CHECK( totals.assertions.failed == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ namespace Catch{
|
|||||||
void MockReporter::Result( const AssertionResult& assertionResult ) {
|
void MockReporter::Result( const AssertionResult& assertionResult ) {
|
||||||
if( assertionResult.getResultType() == ResultWas::Ok )
|
if( assertionResult.getResultType() == ResultWas::Ok )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_log << assertionResult.getSourceInfo() << " ";
|
||||||
|
|
||||||
switch( assertionResult.getResultType() ) {
|
switch( assertionResult.getResultType() ) {
|
||||||
case ResultWas::Info:
|
case ResultWas::Info:
|
||||||
|
@ -551,11 +551,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
|
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = NO;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = NO;
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = CATCH_CONFIG_USE_ANSI_COLOUR_CODES;
|
GCC_PREPROCESSOR_DEFINITIONS = "";
|
||||||
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = (
|
|
||||||
CATCH_CONFIG_USE_ANSI_COLOUR_CODES,
|
|
||||||
"DEBUG=1",
|
|
||||||
);
|
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
WARNING_CFLAGS = (
|
WARNING_CFLAGS = (
|
||||||
"-Weverything",
|
"-Weverything",
|
||||||
|
Loading…
Reference in New Issue
Block a user