Fixed used of cleaned-up context by runner's destructor

This was causing a segfault for some
This commit is contained in:
Phil Nash 2012-05-25 08:52:05 +01:00
parent eb22e212c0
commit 06e959be3e
4 changed files with 107 additions and 47 deletions

View File

@ -39,6 +39,10 @@ namespace Catch {
config.setStreamBuf( ofs.rdbuf() ); config.setStreamBuf( ofs.rdbuf() );
} }
int result = 0;
// Scope here for the Runner so it can use the context before it is cleaned-up
{
Runner runner( config ); Runner runner( config );
// Run test specs specified on the command line - or default to all // Run test specs specified on the command line - or default to all
@ -62,7 +66,8 @@ namespace Catch {
config.getReporter()->EndGroup( *it, runner.getTotals() - prevTotals ); config.getReporter()->EndGroup( *it, runner.getTotals() - prevTotals );
} }
} }
int result = static_cast<int>( runner.getTotals().assertions.failed ); result = static_cast<int>( runner.getTotals().assertions.failed );
}
Catch::Context::cleanUp(); Catch::Context::cleanUp();
return result; return result;
} }

View File

@ -27,6 +27,8 @@ namespace Catch {
struct IContext struct IContext
{ {
virtual ~IContext(){}
virtual IResultCapture& getResultCapture() = 0; virtual IResultCapture& getResultCapture() = 0;
virtual IRunner& getRunner() = 0; virtual IRunner& getRunner() = 0;
virtual IReporterRegistry& getReporterRegistry() = 0; virtual IReporterRegistry& getReporterRegistry() = 0;

View File

@ -362,8 +362,10 @@
ARCHS = "$(ARCHS_STANDARD_64_BIT)"; ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CXX0X_EXTENSIONS = NO; CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
@ -374,14 +376,24 @@
"$(inherited)", "$(inherited)",
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_PEDANTIC = YES; GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES; GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7; MACOSX_DEPLOYMENT_TARGET = 10.7;
@ -397,20 +409,32 @@
ARCHS = "$(ARCHS_STANDARD_64_BIT)"; ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CXX0X_EXTENSIONS = NO; CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_PEDANTIC = YES; GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES; GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7; MACOSX_DEPLOYMENT_TARGET = 10.7;

View File

@ -1,5 +1,5 @@
/* /*
* Generated: 2012-05-24 08:29:19.524673 * Generated: 2012-05-25 08:50:58.340151
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -457,6 +457,8 @@ namespace Catch {
struct IContext struct IContext
{ {
virtual ~IContext(){}
virtual IResultCapture& getResultCapture() = 0; virtual IResultCapture& getResultCapture() = 0;
virtual IRunner& getRunner() = 0; virtual IRunner& getRunner() = 0;
virtual IReporterRegistry& getReporterRegistry() = 0; virtual IReporterRegistry& getReporterRegistry() = 0;
@ -721,7 +723,7 @@ inline std::string toString( bool value ) {
} }
#ifdef CATCH_CONFIG_CPP11_NULLPTR #ifdef CATCH_CONFIG_CPP11_NULLPTR
inline std::string toString( std::nullptr_t null ) { inline std::string toString( std::nullptr_t ) {
return "nullptr"; return "nullptr";
} }
#endif #endif
@ -998,6 +1000,7 @@ namespace Internal {
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs ); return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
} }
// pointer to long (when comparing against NULL)
template<Operator Op, typename T> template<Operator Op, typename T>
bool compare( long lhs, const T* rhs ) { bool compare( long lhs, const T* rhs ) {
return Evaluator<const T*, const T*, Op>::evaluate( reinterpret_cast<const T*>( lhs ), rhs ); return Evaluator<const T*, const T*, Op>::evaluate( reinterpret_cast<const T*>( lhs ), rhs );
@ -1018,6 +1021,27 @@ namespace Internal {
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) ); return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
} }
// pointer to int (when comparing against NULL)
template<Operator Op, typename T>
bool compare( int lhs, const T* rhs ) {
return Evaluator<const T*, const T*, Op>::evaluate( reinterpret_cast<const T*>( lhs ), rhs );
}
template<Operator Op, typename T>
bool compare( int lhs, T* rhs ) {
return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
}
template<Operator Op, typename T>
bool compare( const T* lhs, int rhs ) {
return Evaluator<const T*, const T*, Op>::evaluate( lhs, reinterpret_cast<const T*>( rhs ) );
}
template<Operator Op, typename T>
bool compare( T* lhs, int rhs ) {
return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
}
} // end of namespace Internal } // end of namespace Internal
} // end of namespace Catch } // end of namespace Catch
@ -4484,6 +4508,10 @@ namespace Catch {
config.setStreamBuf( ofs.rdbuf() ); config.setStreamBuf( ofs.rdbuf() );
} }
int result = 0;
// Scope here for the Runner so it can use the context before it is cleaned-up
{
Runner runner( config ); Runner runner( config );
// Run test specs specified on the command line - or default to all // Run test specs specified on the command line - or default to all
@ -4507,7 +4535,8 @@ namespace Catch {
config.getReporter()->EndGroup( *it, runner.getTotals() - prevTotals ); config.getReporter()->EndGroup( *it, runner.getTotals() - prevTotals );
} }
} }
int result = static_cast<int>( runner.getTotals().assertions.failed ); result = static_cast<int>( runner.getTotals().assertions.failed );
}
Catch::Context::cleanUp(); Catch::Context::cleanUp();
return result; return result;
} }