Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

This was causing a segfault for some
  • Loading branch information...
commit 06e959be3ed974932d2ade722a0e6442cfd45fea 1 parent eb22e21
@philsquared authored
View
47 include/catch_runner.hpp
@@ -39,31 +39,36 @@ namespace Catch {
config.setStreamBuf( ofs.rdbuf() );
}
- Runner runner( config );
+ int result = 0;
+
+ // Scope here for the Runner so it can use the context before it is cleaned-up
+ {
+ Runner runner( config );
- // Run test specs specified on the command line - or default to all
- if( !config.testsSpecified() ) {
- config.getReporter()->StartGroup( "" );
- runner.runAll();
- config.getReporter()->EndGroup( "", runner.getTotals() );
- }
- else {
- // !TBD We should get all the testcases upfront, report any missing,
- // then just run them
- std::vector<std::string>::const_iterator it = config.getTestSpecs().begin();
- std::vector<std::string>::const_iterator itEnd = config.getTestSpecs().end();
- for(; it != itEnd; ++it ) {
- Totals prevTotals = runner.getTotals();
- config.getReporter()->StartGroup( *it );
- if( runner.runMatching( *it ) == 0 ) {
- // Use reporter?
-// std::cerr << "\n[Unable to match any test cases with: " << *it << "]" << std::endl;
+ // Run test specs specified on the command line - or default to all
+ if( !config.testsSpecified() ) {
+ config.getReporter()->StartGroup( "" );
+ runner.runAll();
+ config.getReporter()->EndGroup( "", runner.getTotals() );
+ }
+ else {
+ // !TBD We should get all the testcases upfront, report any missing,
+ // then just run them
+ std::vector<std::string>::const_iterator it = config.getTestSpecs().begin();
+ std::vector<std::string>::const_iterator itEnd = config.getTestSpecs().end();
+ for(; it != itEnd; ++it ) {
+ Totals prevTotals = runner.getTotals();
+ config.getReporter()->StartGroup( *it );
+ if( runner.runMatching( *it ) == 0 ) {
+ // Use reporter?
+ // std::cerr << "\n[Unable to match any test cases with: " << *it << "]" << std::endl;
+ }
+ config.getReporter()->EndGroup( *it, runner.getTotals() - prevTotals );
}
- config.getReporter()->EndGroup( *it, runner.getTotals() - prevTotals );
}
+ result = static_cast<int>( runner.getTotals().assertions.failed );
}
- int result = static_cast<int>( runner.getTotals().assertions.failed );
- Catch::Context::cleanUp();
+ Catch::Context::cleanUp();
return result;
}
View
2  include/internal/catch_context.h
@@ -27,6 +27,8 @@ namespace Catch {
struct IContext
{
+ virtual ~IContext(){}
+
virtual IResultCapture& getResultCapture() = 0;
virtual IRunner& getRunner() = 0;
virtual IReporterRegistry& getReporterRegistry() = 0;
View
28 projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
@@ -362,8 +362,10 @@
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
- CLANG_WARN_CXX0X_EXTENSIONS = NO;
+ CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
@@ -374,14 +376,24 @@
"$(inherited)",
);
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_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = 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_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_PEDANTIC = 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_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
@@ -397,20 +409,32 @@
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
- CLANG_WARN_CXX0X_EXTENSIONS = NO;
+ CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
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_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = 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_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_PEDANTIC = 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_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
View
73 single_include/catch.hpp
@@ -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
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -457,6 +457,8 @@ namespace Catch {
struct IContext
{
+ virtual ~IContext(){}
+
virtual IResultCapture& getResultCapture() = 0;
virtual IRunner& getRunner() = 0;
virtual IReporterRegistry& getReporterRegistry() = 0;
@@ -721,7 +723,7 @@ inline std::string toString( bool value ) {
}
#ifdef CATCH_CONFIG_CPP11_NULLPTR
-inline std::string toString( std::nullptr_t null ) {
+inline std::string toString( std::nullptr_t ) {
return "nullptr";
}
#endif
@@ -998,6 +1000,7 @@ namespace Internal {
return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
}
+ // pointer to long (when comparing against NULL)
template<Operator Op, typename T>
bool compare( long lhs, const T* 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 ) );
}
+ // 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 Catch
@@ -4484,30 +4508,35 @@ namespace Catch {
config.setStreamBuf( ofs.rdbuf() );
}
- Runner runner( config );
+ int result = 0;
- // Run test specs specified on the command line - or default to all
- if( !config.testsSpecified() ) {
- config.getReporter()->StartGroup( "" );
- runner.runAll();
- config.getReporter()->EndGroup( "", runner.getTotals() );
- }
- else {
- // !TBD We should get all the testcases upfront, report any missing,
- // then just run them
- std::vector<std::string>::const_iterator it = config.getTestSpecs().begin();
- std::vector<std::string>::const_iterator itEnd = config.getTestSpecs().end();
- for(; it != itEnd; ++it ) {
- Totals prevTotals = runner.getTotals();
- config.getReporter()->StartGroup( *it );
- if( runner.runMatching( *it ) == 0 ) {
- // Use reporter?
-// std::cerr << "\n[Unable to match any test cases with: " << *it << "]" << std::endl;
+ // Scope here for the Runner so it can use the context before it is cleaned-up
+ {
+ Runner runner( config );
+
+ // Run test specs specified on the command line - or default to all
+ if( !config.testsSpecified() ) {
+ config.getReporter()->StartGroup( "" );
+ runner.runAll();
+ config.getReporter()->EndGroup( "", runner.getTotals() );
+ }
+ else {
+ // !TBD We should get all the testcases upfront, report any missing,
+ // then just run them
+ std::vector<std::string>::const_iterator it = config.getTestSpecs().begin();
+ std::vector<std::string>::const_iterator itEnd = config.getTestSpecs().end();
+ for(; it != itEnd; ++it ) {
+ Totals prevTotals = runner.getTotals();
+ config.getReporter()->StartGroup( *it );
+ if( runner.runMatching( *it ) == 0 ) {
+ // Use reporter?
+ // std::cerr << "\n[Unable to match any test cases with: " << *it << "]" << std::endl;
+ }
+ config.getReporter()->EndGroup( *it, runner.getTotals() - prevTotals );
}
- config.getReporter()->EndGroup( *it, runner.getTotals() - prevTotals );
}
+ result = static_cast<int>( runner.getTotals().assertions.failed );
}
- int result = static_cast<int>( runner.getTotals().assertions.failed );
Catch::Context::cleanUp();
return result;
}
Please sign in to comment.
Something went wrong with that request. Please try again.