diff options
| author | Phil Nash | 2012-05-25 08:52:05 +0100 |
|---|---|---|
| committer | Phil Nash | 2012-05-25 08:52:05 +0100 |
| commit | 06e959be3ed974932d2ade722a0e6442cfd45fea (patch) | |
| tree | e0bfd94d86d5f7721a667a81b4874882897dfc96 /include | |
| parent | eb22e212c0f374410533cd2e3dfa7869baf6f6d3 (diff) | |
| download | catch3-06e959be3ed974932d2ade722a0e6442cfd45fea.tar.gz | |
Fixed used of cleaned-up context by runner's destructor
This was causing a segfault for some
Diffstat (limited to 'include')
| -rw-r--r-- | include/catch_runner.hpp | 47 | ||||
| -rw-r--r-- | include/internal/catch_context.h | 2 |
2 files changed, 28 insertions, 21 deletions
diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp index ed16b342..e9f8da7f 100644 --- a/include/catch_runner.hpp +++ b/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; } diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h index 8611064e..87ff522e 100644 --- a/include/internal/catch_context.h +++ b/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; |