Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Builds almost completely cleanly with -WEverything in LLVM

Commit
a695eb90064408d690f29e15a587b9db9323c43c
Author
Phil Nash ·
Parents
cdc64a138bd0

Files · Download .tar.gz

Changes

 include/catch.hpp                                  |    9 +-
 include/catch_runner.hpp                           |    6 +-
 include/catch_with_main.hpp                        |    2 +-
 include/internal/catch_commandline.hpp             |    4 +-
 include/internal/catch_common.h                    |   21 +-
 include/internal/catch_config.hpp                  |    5 +-
 include/internal/catch_context.h                   |    8 +-
 include/internal/catch_impl.hpp                    |   37 +
 include/internal/catch_interfaces_capture.h        |    2 +-
 include/internal/catch_interfaces_config.h         |    2 +-
 include/internal/catch_interfaces_exception.h      |    4 +-
 include/internal/catch_interfaces_generators.h     |    4 +-
 include/internal/catch_interfaces_registry_hub.h   |    4 +-
 include/internal/catch_interfaces_reporter.h       |    6 +-
 include/internal/catch_interfaces_runner.h         |    2 +-
 include/internal/catch_interfaces_testcase.h       |    4 +-
 include/internal/catch_ptr.hpp                     |    2 +-
 include/internal/catch_reporter_registry.hpp       |    2 +-
 include/internal/catch_resultinfo.h                |    2 +-
 include/internal/catch_runner_impl.hpp             |    2 +-
 include/internal/catch_test_case_registry_impl.hpp |    2 +
 include/internal/catch_test_registry.hpp           |    2 +-
 include/reporters/catch_reporter_basic.hpp         |    5 +-
 include/reporters/catch_reporter_junit.hpp         |    5 +-
 include/reporters/catch_reporter_xml.hpp           |    2 +-
 projects/SelfTest/ApproxTests.cpp                  |    4 -
 projects/SelfTest/ClassTests.cpp                   |    4 -
 projects/SelfTest/ConditionTests.cpp               |    5 +-
 projects/SelfTest/ExceptionTests.cpp               |    9 +-
 projects/SelfTest/GeneratorTests.cpp               |    4 -
 projects/SelfTest/MessageTests.cpp                 |    4 -
 projects/SelfTest/MiscTests.cpp                    |    5 +-
 projects/SelfTest/TestMain.cpp                     |    4 +
 projects/SelfTest/TrickyTests.cpp                  |    6 +-
 projects/SelfTest/catch_self_test.cpp              |    9 +-
 .../CatchSelfTest.xcodeproj/project.pbxproj        |   14 +
 single_include/catch.hpp                           | 2835 ++++++++++----------
 37 files changed, 1563 insertions(+), 1484 deletions(-)

diff --git a/include/catch.hpp b/include/catch.hpp
index f0dd7c9e..1064ddd7 100644
--- a/include/catch.hpp
+++ b/include/catch.hpp
@@ -9,6 +9,12 @@
 #ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
 #define TWOBLUECUBES_CATCH_HPP_INCLUDED
 
+#pragma clang diagnostic ignored "-Wno-global-constructors"
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+
+
 #include "internal/catch_notimplemented_exception.h"
 #include "internal/catch_context.h"
 #include "internal/catch_test_registry.hpp"
@@ -29,7 +35,6 @@
 #endif
 
 #if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER )
-#include "catch_runner.hpp"
 #include "internal/catch_impl.hpp"
 #endif
 
@@ -127,4 +132,6 @@
 
 using Catch::Detail::Approx;
 
+#pragma clang diagnostic pop
+
 #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED
diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp
index 4ae06f85..b66fec31 100644
--- a/include/catch_runner.hpp
+++ b/include/catch_runner.hpp
@@ -8,12 +8,14 @@
 #ifndef TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
 #define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
 
-#include "internal/catch_commandline.hpp"
-#include "internal/catch_list.hpp"
 #include "reporters/catch_reporter_basic.hpp"
 #include "reporters/catch_reporter_xml.hpp"
 #include "reporters/catch_reporter_junit.hpp"
 
+#include "internal/catch_commandline.hpp"
+#include "internal/catch_list.hpp"
+#include "internal/catch_runner_impl.hpp"
+
 #include <fstream>
 #include <stdlib.h>
 #include <limits>
diff --git a/include/catch_with_main.hpp b/include/catch_with_main.hpp
index 45356ec9..23855e9b 100644
--- a/include/catch_with_main.hpp
+++ b/include/catch_with_main.hpp
@@ -1,4 +1,4 @@
-/*
+ /*
  *  Created by Phil on 01/11/2010.
  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
  *
diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp
index d25e33e2..d1b39a82 100644
--- a/include/internal/catch_commandline.hpp
+++ b/include/internal/catch_commandline.hpp
@@ -9,7 +9,6 @@
 #define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
 
 #include "catch_config.hpp"
-#include "catch_runner_impl.hpp"
 
 namespace Catch {
 
@@ -42,7 +41,8 @@ namespace Catch {
         std::string name() const { return m_name; }
         std::string operator[]( std::size_t i ) const { return m_args[i]; }
         std::size_t argsCount() const { return m_args.size(); }
-        
+
+        CATCH_ATTRIBUTE_NORETURN
         void raiseError( const std::string& message ) const {
             std::ostringstream oss;
             oss << "Error while parsing " << m_name << ". " << message << ".";
diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h
index 624966d0..ee4a565b 100644
--- a/include/internal/catch_common.h
+++ b/include/internal/catch_common.h
@@ -16,9 +16,9 @@
 #define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
 
 #ifdef __GNUC__
-#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
+#define CATCH_ATTRIBUTE_NORETURN __attribute__ ((noreturn))
 #else
-#define ATTRIBUTE_NORETURN
+#define CATCH_ATTRIBUTE_NORETURN
 #endif
 
 #include <sstream>
@@ -32,7 +32,7 @@ namespace Catch {
 		void operator = ( const NonCopyable& );
 	protected:
 		NonCopyable() {}
-		virtual ~NonCopyable() {}
+		virtual ~NonCopyable();
 	};
     
     class SafeBool {
@@ -110,21 +110,16 @@ namespace Catch {
         return os;
     }
     
-    ATTRIBUTE_NORETURN
-    inline void throwLogicError( const std::string& message, const std::string& file, std::size_t line ) {
+    CATCH_ATTRIBUTE_NORETURN
+    inline void throwLogicError( const std::string& message, const SourceLineInfo& locationInfo ) {
         std::ostringstream oss;
-        oss << "Internal Catch error: '" << message << "' at: " << SourceLineInfo( file, line );
+        oss << "Internal Catch error: '" << message << "' at: " << locationInfo;
         throw std::logic_error( oss.str() );
     }
 }
 
-#define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ );
-
-//#ifdef __FUNCTION__
-//#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FUNCTION__, __FILE__, __LINE__ )
-//#else
-#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ )
-//#endif
+#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
+#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
 
 #endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
 
diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp
index 7f8e2a2d..fa488095 100644
--- a/include/internal/catch_config.hpp
+++ b/include/internal/catch_config.hpp
@@ -64,8 +64,9 @@ namespace Catch {
     private:
         Config( const Config& other );
         Config& operator = ( const Config& other );
+        virtual void dummy();
     public:
-                
+
         Config()
         :   m_streambuf( NULL ),
             m_os( std::cout.rdbuf() )
@@ -77,7 +78,7 @@ namespace Catch {
             m_os( std::cout.rdbuf() )
         {}
         
-        ~Config() {
+        virtual ~Config() {
             m_os.rdbuf( std::cout.rdbuf() );
             delete m_streambuf;
         }
diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h
index 005b0bfa..c3460e3d 100644
--- a/include/internal/catch_context.h
+++ b/include/internal/catch_context.h
@@ -23,11 +23,14 @@ namespace Catch {
     struct IRunner;
     struct IGeneratorsForTest;
 
-    class StreamBufBase : public std::streambuf{};
+    class StreamBufBase : public std::streambuf {
+    public:
+        virtual ~StreamBufBase();
+    };
     
     struct IContext
     {
-        virtual ~IContext(){}
+        virtual ~IContext();
         
         virtual IResultCapture& getResultCapture() = 0;
         virtual IRunner& getRunner() = 0;
@@ -38,6 +41,7 @@ namespace Catch {
     
     struct IMutableContext : IContext
     {
+        virtual ~IMutableContext();
         virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
         virtual void setRunner( IRunner* runner ) = 0;
         virtual void setConfig( const IConfig* config ) = 0;
diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp
index 5320d8d8..6bb11e77 100644
--- a/include/internal/catch_impl.hpp
+++ b/include/internal/catch_impl.hpp
@@ -8,6 +8,11 @@
 
 // Collect all the implementation files together here
 // These are the equivalent of what would usually be cpp files
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wweak-vtables"
+
+#include "catch_runner.hpp"
 #include "catch_registry_hub.hpp"
 #include "catch_notimplemented_exception.hpp"
 #include "catch_context_impl.hpp"
@@ -15,3 +20,35 @@
 #include "catch_generators_impl.hpp"
 #include "catch_resultinfo.hpp"
 #include "catch_resultinfo_builder.hpp"
+
+namespace Catch {
+    NonCopyable::~NonCopyable() {}
+    IShared::~IShared() {}
+    StreamBufBase::~StreamBufBase() {}
+    IContext::~IContext() {}
+    IResultCapture::~IResultCapture() {}
+    ITestCase::~ITestCase() {}
+    ITestCaseRegistry::~ITestCaseRegistry() {}
+    IRegistryHub::~IRegistryHub() {}
+    IMutableRegistryHub::~IMutableRegistryHub() {}
+    IExceptionTranslator::~IExceptionTranslator() {}
+    IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
+    IReporter::~IReporter() {}
+    IReporterFactory::~IReporterFactory() {}
+    IReporterRegistry::~IReporterRegistry() {}
+    BasicReporter::~BasicReporter() {}
+    IRunner::~IRunner() {}
+    IMutableContext::~IMutableContext() {}
+    IConfig::~IConfig() {}
+    XmlReporter::~XmlReporter() {}
+    JunitReporter::~JunitReporter() {}
+    TestRegistry::~TestRegistry() {}
+    FreeFunctionTestCase::~FreeFunctionTestCase() {}
+    IGeneratorInfo::~IGeneratorInfo() {}
+    IGeneratorsForTest::~IGeneratorsForTest() {}
+
+    void Config::dummy() {}
+
+}
+
+#pragma clang diagnostic pop
diff --git a/include/internal/catch_interfaces_capture.h b/include/internal/catch_interfaces_capture.h
index 4cb74a06..c50d914b 100644
--- a/include/internal/catch_interfaces_capture.h
+++ b/include/internal/catch_interfaces_capture.h
@@ -21,7 +21,7 @@ namespace Catch {
 
     struct IResultCapture {
     
-        virtual ~IResultCapture(){}
+        virtual ~IResultCapture();
         
         virtual void testEnded( const ResultInfo& result ) = 0;
         virtual bool sectionStarted(    const std::string& name, 
diff --git a/include/internal/catch_interfaces_config.h b/include/internal/catch_interfaces_config.h
index ec434e5d..01abe56e 100644
--- a/include/internal/catch_interfaces_config.h
+++ b/include/internal/catch_interfaces_config.h
@@ -12,7 +12,7 @@ namespace Catch {
 
     struct IConfig {
     
-        virtual ~IConfig(){}
+        virtual ~IConfig();
         
         virtual bool allowThrows() const = 0;
     };
diff --git a/include/internal/catch_interfaces_exception.h b/include/internal/catch_interfaces_exception.h
index 9054dfe4..76146129 100644
--- a/include/internal/catch_interfaces_exception.h
+++ b/include/internal/catch_interfaces_exception.h
@@ -16,12 +16,12 @@ namespace Catch {
     typedef std::string(*exceptionTranslateFunction)();
 
     struct IExceptionTranslator {
-        virtual ~IExceptionTranslator(){}
+        virtual ~IExceptionTranslator();
         virtual std::string translate() const = 0;
     };
     
     struct IExceptionTranslatorRegistry {
-        virtual ~IExceptionTranslatorRegistry(){}
+        virtual ~IExceptionTranslatorRegistry();
         
         virtual std::string translateActiveException() const = 0;
     };
diff --git a/include/internal/catch_interfaces_generators.h b/include/internal/catch_interfaces_generators.h
index ef651edc..8907adb6 100644
--- a/include/internal/catch_interfaces_generators.h
+++ b/include/internal/catch_interfaces_generators.h
@@ -13,13 +13,13 @@
 namespace Catch {
 
     struct IGeneratorInfo {
-        virtual ~IGeneratorInfo(){}
+        virtual ~IGeneratorInfo();
         virtual bool moveNext() = 0;
         virtual std::size_t getCurrentIndex() const = 0;
     };
     
     struct IGeneratorsForTest {
-        virtual ~IGeneratorsForTest() {}
+        virtual ~IGeneratorsForTest();
 
         virtual IGeneratorInfo& getGeneratorInfo( const std::string& fileInfo, std::size_t size ) = 0;
         virtual bool moveNext() = 0;
diff --git a/include/internal/catch_interfaces_registry_hub.h b/include/internal/catch_interfaces_registry_hub.h
index e935340f..0da503bd 100644
--- a/include/internal/catch_interfaces_registry_hub.h
+++ b/include/internal/catch_interfaces_registry_hub.h
@@ -24,7 +24,7 @@ namespace Catch {
     struct IExceptionTranslator;
 
     struct IRegistryHub {
-        virtual ~IRegistryHub(){}
+        virtual ~IRegistryHub();
 
         virtual const IReporterRegistry& getReporterRegistry() const = 0;
         virtual const ITestCaseRegistry& getTestCaseRegistry() const = 0;
@@ -32,7 +32,7 @@ namespace Catch {
     };
 
     struct IMutableRegistryHub {
-        virtual ~IMutableRegistryHub(){}
+        virtual ~IMutableRegistryHub();
         virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
         virtual void registerTest( const TestCaseInfo& testInfo ) = 0;
         virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h
index dddba174..f6b90872 100644
--- a/include/internal/catch_interfaces_reporter.h
+++ b/include/internal/catch_interfaces_reporter.h
@@ -37,7 +37,7 @@ namespace Catch
     class ResultInfo;
     
     struct IReporter : IShared {
-        virtual ~IReporter() {}        
+        virtual ~IReporter();
         virtual bool shouldRedirectStdout() const = 0;        
         virtual void StartTesting() = 0;        
         virtual void EndTesting( const Totals& totals ) = 0;        
@@ -52,7 +52,7 @@ namespace Catch
     };
     
     struct IReporterFactory {
-        virtual ~IReporterFactory() {}        
+        virtual ~IReporterFactory();
         virtual IReporter* create( const ReporterConfig& config ) const = 0;
         virtual std::string getDescription() const = 0;
     };
@@ -60,7 +60,7 @@ namespace Catch
     struct IReporterRegistry {
         typedef std::map<std::string, IReporterFactory*> FactoryMap;
 
-        virtual ~IReporterRegistry() {}
+        virtual ~IReporterRegistry();
         virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const = 0;        
         virtual const FactoryMap& getFactories() const = 0;
     };
diff --git a/include/internal/catch_interfaces_runner.h b/include/internal/catch_interfaces_runner.h
index ee7b3486..b932e65f 100644
--- a/include/internal/catch_interfaces_runner.h
+++ b/include/internal/catch_interfaces_runner.h
@@ -16,7 +16,7 @@ namespace Catch {
     class TestCaseInfo;
     
     struct IRunner {
-        virtual ~IRunner() {}        
+        virtual ~IRunner();
         virtual void runAll( bool runHiddenTests = false ) = 0;        
         virtual std::size_t runMatching( const std::string& rawTestSpec ) = 0;        
         virtual Totals getTotals() const = 0;
diff --git a/include/internal/catch_interfaces_testcase.h b/include/internal/catch_interfaces_testcase.h
index f4ba5621..f3ccb58d 100644
--- a/include/internal/catch_interfaces_testcase.h
+++ b/include/internal/catch_interfaces_testcase.h
@@ -12,7 +12,7 @@
 
 namespace Catch {
     struct ITestCase {
-        virtual ~ITestCase(){}
+        virtual ~ITestCase();
         virtual void invoke () const = 0;        
         virtual ITestCase* clone() const = 0;        
         virtual bool operator == ( const ITestCase& other ) const = 0;        
@@ -22,7 +22,7 @@ namespace Catch {
     class TestCaseInfo;
 
     struct ITestCaseRegistry {
-        virtual ~ITestCaseRegistry(){}
+        virtual ~ITestCaseRegistry();
         virtual const std::vector<TestCaseInfo>& getAllTests() const = 0;
         virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const = 0;
     };
diff --git a/include/internal/catch_ptr.hpp b/include/internal/catch_ptr.hpp
index 73e53ac9..3976b7e9 100644
--- a/include/internal/catch_ptr.hpp
+++ b/include/internal/catch_ptr.hpp
@@ -74,7 +74,7 @@ namespace Catch {
     };
     
     struct IShared : NonCopyable {
-        virtual ~IShared(){}
+        virtual ~IShared();
         virtual void addRef() = 0;
         virtual void release() = 0;
     };
diff --git a/include/internal/catch_reporter_registry.hpp b/include/internal/catch_reporter_registry.hpp
index 485cb3bf..21a48962 100644
--- a/include/internal/catch_reporter_registry.hpp
+++ b/include/internal/catch_reporter_registry.hpp
@@ -18,7 +18,7 @@ namespace Catch {
     
     public:
         
-        ~ReporterRegistry() {
+        virtual ~ReporterRegistry() {
             deleteAllValues( m_factories );
         }
         
diff --git a/include/internal/catch_resultinfo.h b/include/internal/catch_resultinfo.h
index 3ca6276e..fb49649d 100644
--- a/include/internal/catch_resultinfo.h
+++ b/include/internal/catch_resultinfo.h
@@ -22,7 +22,7 @@ namespace Catch {
                     const SourceLineInfo& lineInfo,
                     const char* macroName,
                    const char* message );
-        virtual ~ResultInfo();
+        ~ResultInfo();
         
         bool ok() const;
         ResultWas::OfType getResultType() const;
diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp
index 6e4b0c0a..15b60743 100644
--- a/include/internal/catch_runner_impl.hpp
+++ b/include/internal/catch_runner_impl.hpp
@@ -70,7 +70,7 @@ namespace Catch {
             m_reporter->StartTesting();
         }
         
-        ~Runner() {
+        virtual ~Runner() {
             m_reporter->EndTesting( m_totals );
             m_context.setRunner( m_prevRunner );
             m_context.setConfig( NULL );
diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp
index 46d2805e..5e23fed9 100644
--- a/include/internal/catch_test_case_registry_impl.hpp
+++ b/include/internal/catch_test_case_registry_impl.hpp
@@ -19,6 +19,7 @@ namespace Catch {
     class TestRegistry : public ITestCaseRegistry {
     public:
         TestRegistry() : m_unnamedCount( 0 ) {}
+        virtual ~TestRegistry();
         
         virtual void registerTest( const TestCaseInfo& testInfo ) {
             if( testInfo.getName() == "" ) {
@@ -71,6 +72,7 @@ namespace Catch {
     public:
 
         FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
+        virtual ~FreeFunctionTestCase();
         
         virtual void invoke() const {
             m_fun();
diff --git a/include/internal/catch_test_registry.hpp b/include/internal/catch_test_registry.hpp
index f25dedd1..5a0ef0d9 100644
--- a/include/internal/catch_test_registry.hpp
+++ b/include/internal/catch_test_registry.hpp
@@ -81,7 +81,7 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_TESTCASE_NORETURN( Name, Desc ) \
-    static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )() ATTRIBUTE_NORETURN; \
+    static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )() CATCH_ATTRIBUTE_NORETURN; \
     namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ ), Name, Desc, CATCH_INTERNAL_LINEINFO ); }\
     static void INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ )()
 
diff --git a/include/reporters/catch_reporter_basic.hpp b/include/reporters/catch_reporter_basic.hpp
index 87769ee3..0e1edc1e 100644
--- a/include/reporters/catch_reporter_basic.hpp
+++ b/include/reporters/catch_reporter_basic.hpp
@@ -35,7 +35,7 @@ namespace Catch {
     class BasicReporter : public SharedImpl<IReporter> {
     
         struct SpanInfo {
-        
+
             SpanInfo() 
             :   emitted( false )
             {}
@@ -60,6 +60,8 @@ namespace Catch {
             m_firstSectionInTestCase( true ),
             m_aborted( false )
         {}
+
+        virtual ~BasicReporter();
         
         static std::string getDescription() {
             return "Reports test results as lines of text";
@@ -222,7 +224,6 @@ namespace Catch {
                 case ResultWas::FailureBit:
                 case ResultWas::ExpressionFailed:
                 case ResultWas::Exception:
-                default:
                     if( !resultInfo.hasExpression() ) {
                         if( resultInfo.ok() ) {
                             TextColour colour( TextColour::Success );
diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp
index 12757620..d1633dcb 100644
--- a/include/reporters/catch_reporter_junit.hpp
+++ b/include/reporters/catch_reporter_junit.hpp
@@ -61,7 +61,8 @@ namespace Catch {
         :   m_config( config ),
             m_testSuiteStats( "AllTests" ),
             m_currentStats( &m_testSuiteStats )
-        {}        
+        {}
+        virtual ~JunitReporter();
         
         static std::string getDescription() {
             return "Reports test results in an XML format that looks like Ant's junitreport target";
@@ -131,8 +132,6 @@ namespace Catch {
                     case ResultWas::FailureBit:
                     case ResultWas::Exception:
                     case ResultWas::DidntThrowException:
-                    default:
-                        stats.m_element = "unknown";
                         break;
                 }
                 testCaseStats.m_testStats.push_back( stats );                
diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp
index ed627e36..9e6a345e 100644
--- a/include/reporters/catch_reporter_xml.hpp
+++ b/include/reporters/catch_reporter_xml.hpp
@@ -21,6 +21,7 @@ namespace Catch {
         static std::string getDescription() {
             return "Reports test results as an XML document";
         }
+        virtual ~XmlReporter();
         
     private: // IReporter
 
@@ -116,7 +117,6 @@ namespace Catch {
                 case ResultWas::ExpressionFailed:
                 case ResultWas::Exception:
                 case ResultWas::DidntThrowException:
-                default:
                     break;
             }            
             if( resultInfo.hasExpression() )
diff --git a/projects/SelfTest/ApproxTests.cpp b/projects/SelfTest/ApproxTests.cpp
index f9addb4e..5101c865 100644
--- a/projects/SelfTest/ApproxTests.cpp
+++ b/projects/SelfTest/ApproxTests.cpp
@@ -1,13 +1,9 @@
 /*
- *  ApproxTests.cpp
- *  Catch - Test
- *
  *  Created by Phil on 28/04/2011.
  *  Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
 
 #include "catch.hpp"
diff --git a/projects/SelfTest/ClassTests.cpp b/projects/SelfTest/ClassTests.cpp
index 31713ea2..76c06dd7 100644
--- a/projects/SelfTest/ClassTests.cpp
+++ b/projects/SelfTest/ClassTests.cpp
@@ -1,13 +1,9 @@
 /*
- *  ClassTests.cpp
- *  Catch - Test
- *
  *  Created by Phil on 09/11/2010.
  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
 
 #include "catch.hpp"
diff --git a/projects/SelfTest/ConditionTests.cpp b/projects/SelfTest/ConditionTests.cpp
index db70611b..cd874c39 100644
--- a/projects/SelfTest/ConditionTests.cpp
+++ b/projects/SelfTest/ConditionTests.cpp
@@ -1,14 +1,11 @@
 /*
- *  ConditionTests.cpp
- *  Catch - Test
- *
  *  Created by Phil on 08/11/2010.
  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
+#pragma clang diagnostic ignored "-Wpadded"
 
 #include "catch.hpp"
 
diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp
index 8d8eb552..a6c2a60f 100644
--- a/projects/SelfTest/ExceptionTests.cpp
+++ b/projects/SelfTest/ExceptionTests.cpp
@@ -1,15 +1,13 @@
 /*
- *  ExceptionTests.cpp
- *  Catch - Test
- *
  *  Created by Phil on 09/11/2010.
  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
 
+#pragma clang diagnostic ignored "-Wpadded"
+
 #include "catch.hpp"
 
 #include <string>
@@ -19,7 +17,7 @@
 
 namespace
 {
-    ATTRIBUTE_NORETURN
+    CATCH_ATTRIBUTE_NORETURN
     int thisThrows();
     
     int thisThrows()
@@ -41,6 +39,7 @@ TEST_CASE( "./succeeding/exceptions/explicit", "When checked exceptions are thro
     REQUIRE_THROWS( thisThrows() );
 }
 
+CATCH_ATTRIBUTE_NORETURN
 TEST_CASE( "./failing/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" )
 {
     CHECK_THROWS_AS( thisThrows(), std::string );
diff --git a/projects/SelfTest/GeneratorTests.cpp b/projects/SelfTest/GeneratorTests.cpp
index fe843bd3..700b180b 100644
--- a/projects/SelfTest/GeneratorTests.cpp
+++ b/projects/SelfTest/GeneratorTests.cpp
@@ -1,13 +1,9 @@
 /*
- *  GeneratorTests.cpp
- *  Catch - Test
- *
  *  Created by Phil on 28/01/2011.
  *  Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
 
 // This define means we have to prefix all the CATCH macros with CATCH_
diff --git a/projects/SelfTest/MessageTests.cpp b/projects/SelfTest/MessageTests.cpp
index d7c148f6..36a5071a 100644
--- a/projects/SelfTest/MessageTests.cpp
+++ b/projects/SelfTest/MessageTests.cpp
@@ -1,13 +1,9 @@
 /*
- *  MessageTests.cpp
- *  Catch - Test
- *
  *  Created by Phil on 09/11/2010.
  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
 
 #include "catch.hpp"
diff --git a/projects/SelfTest/MiscTests.cpp b/projects/SelfTest/MiscTests.cpp
index cacc3f31..f9a9bad7 100644
--- a/projects/SelfTest/MiscTests.cpp
+++ b/projects/SelfTest/MiscTests.cpp
@@ -1,14 +1,11 @@
 /*
- *  MiscTests.cpp
- *  Catch - Test
- *
  *  Created by Phil on 29/11/2010.
  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
+#pragma clang diagnostic ignored "-Wpadded"
 
 #include "catch.hpp"
 #include "catch_self_test.hpp"
diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp
index 15616ee3..324fc28c 100644
--- a/projects/SelfTest/TestMain.cpp
+++ b/projects/SelfTest/TestMain.cpp
@@ -5,6 +5,8 @@
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  */
+#pragma clang diagnostic ignored "-Wpadded"
+
 #include "catch_self_test.hpp"
 
 TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results" ) {
@@ -54,6 +56,8 @@ TEST_CASE( "meta/Misc/Sections", "looped tests" ) {
     CHECK( runner.getTotals().assertions.failed == 1 );
 }
 
+#pragma clang diagnostic ignored "-Wweak-vtables"
+
 #include "../../include/internal/catch_commandline.hpp"
 #include "../../include/reporters/catch_reporter_basic.hpp"
 #include "../../include/reporters/catch_reporter_xml.hpp"
diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp
index ee7d236e..f1b0342a 100644
--- a/projects/SelfTest/TrickyTests.cpp
+++ b/projects/SelfTest/TrickyTests.cpp
@@ -1,15 +1,13 @@
 /*
- *  TrickyTests.cpp
- *  Catch - Test
- *
  *  Created by Phil on 09/11/2010.
  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
 
+#pragma clang diagnostic ignored "-Wpadded"
+
 #include "catch.hpp"
 
 namespace Catch
diff --git a/projects/SelfTest/catch_self_test.cpp b/projects/SelfTest/catch_self_test.cpp
index 96ffdbd4..d0065a78 100644
--- a/projects/SelfTest/catch_self_test.cpp
+++ b/projects/SelfTest/catch_self_test.cpp
@@ -1,15 +1,13 @@
 /*
- *  catch_self_test.cpp
- *  Catch
- *
  *  Created by Phil on 14/02/2012.
  *  Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
  *
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- *
  */
 
+#pragma clang diagnostic ignored "-Wpadded"
+
 #define CATCH_CONFIG_MAIN
 #include "catch_self_test.hpp"
 
@@ -69,9 +67,6 @@ namespace Catch{
             case ResultWas::Exception:
                 m_log << "Exception";
                 break;
-            default:
-                m_log << "{unrecognised ResultType enum value}";
-                break;
         }
         
         if( resultInfo.hasExpression() )
diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
index ac89c59a..437b1375 100644
--- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
+++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
@@ -465,14 +465,28 @@
 		4A6D0C2B149B3D3B00DB3EAA /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = NO;
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				WARNING_CFLAGS = (
+					"-Weverything",
+					"-Wno-disabled-macro-expansion",
+					"-Wno-global-constructors",
+				);
 			};
 			name = Debug;
 		};
 		4A6D0C2C149B3D3B00DB3EAA /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = NO;
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				WARNING_CFLAGS = (
+					"-Weverything",
+					"-Wno-disabled-macro-expansion",
+					"-Wno-global-constructors",
+				);
 			};
 			name = Release;
 		};
diff --git a/single_include/catch.hpp b/single_include/catch.hpp
index c8a405a6..e19cf6b4 100644
--- a/single_include/catch.hpp
+++ b/single_include/catch.hpp
@@ -1,5 +1,5 @@
 /*
- *  Generated: 2012-08-09 07:45:58.677223
+ *  Generated: 2012-08-12 09:51:33.273449
  *  ----------------------------------------------------------
  *  This file has been merged from multiple headers. Please don't edit it directly
  *  Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -12,6 +12,9 @@
 
 #define TWOBLUECUBES_CATCH_HPP_INCLUDED
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+
 // #included from: internal/catch_notimplemented_exception.h
 #define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
 
@@ -26,9 +29,9 @@
 #define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
 
 #ifdef __GNUC__
-#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
+#define CATCH_ATTRIBUTE_NORETURN __attribute__ ((noreturn))
 #else
-#define ATTRIBUTE_NORETURN
+#define CATCH_ATTRIBUTE_NORETURN
 #endif
 
 #include <sstream>
@@ -42,7 +45,7 @@ namespace Catch {
 		void operator = ( const NonCopyable& );
 	protected:
 		NonCopyable() {}
-		virtual ~NonCopyable() {}
+		virtual ~NonCopyable();
 	};
 
     class SafeBool {
@@ -120,21 +123,16 @@ namespace Catch {
         return os;
     }
 
-    ATTRIBUTE_NORETURN
-    inline void throwLogicError( const std::string& message, const std::string& file, std::size_t line ) {
+    CATCH_ATTRIBUTE_NORETURN
+    inline void throwLogicError( const std::string& message, const SourceLineInfo& locationInfo ) {
         std::ostringstream oss;
-        oss << "Internal Catch error: '" << message << "' at: " << SourceLineInfo( file, line );
+        oss << "Internal Catch error: '" << message << "' at: " << locationInfo;
         throw std::logic_error( oss.str() );
     }
 }
 
-#define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ );
-
-//#ifdef __FUNCTION__
-//#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FUNCTION__, __FILE__, __LINE__ )
-//#else
-#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ )
-//#endif
+#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
+#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
 
 #include <ostream>
 
@@ -283,7 +281,7 @@ namespace Catch {
     };
 
     struct IShared : NonCopyable {
-        virtual ~IShared(){}
+        virtual ~IShared();
         virtual void addRef() = 0;
         virtual void release() = 0;
     };
@@ -331,7 +329,7 @@ namespace Catch
     class ResultInfo;
 
     struct IReporter : IShared {
-        virtual ~IReporter() {}
+        virtual ~IReporter();
         virtual bool shouldRedirectStdout() const = 0;
         virtual void StartTesting() = 0;
         virtual void EndTesting( const Totals& totals ) = 0;
@@ -346,7 +344,7 @@ namespace Catch
     };
 
     struct IReporterFactory {
-        virtual ~IReporterFactory() {}
+        virtual ~IReporterFactory();
         virtual IReporter* create( const ReporterConfig& config ) const = 0;
         virtual std::string getDescription() const = 0;
     };
@@ -354,7 +352,7 @@ namespace Catch
     struct IReporterRegistry {
         typedef std::map<std::string, IReporterFactory*> FactoryMap;
 
-        virtual ~IReporterRegistry() {}
+        virtual ~IReporterRegistry();
         virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const = 0;
         virtual const FactoryMap& getFactories() const = 0;
     };
@@ -374,7 +372,7 @@ namespace Catch {
 
     struct IConfig {
 
-        virtual ~IConfig(){}
+        virtual ~IConfig();
 
         virtual bool allowThrows() const = 0;
     };
@@ -388,13 +386,13 @@ namespace Catch {
 namespace Catch {
 
     struct IGeneratorInfo {
-        virtual ~IGeneratorInfo(){}
+        virtual ~IGeneratorInfo();
         virtual bool moveNext() = 0;
         virtual std::size_t getCurrentIndex() const = 0;
     };
 
     struct IGeneratorsForTest {
-        virtual ~IGeneratorsForTest() {}
+        virtual ~IGeneratorsForTest();
 
         virtual IGeneratorInfo& getGeneratorInfo( const std::string& fileInfo, std::size_t size ) = 0;
         virtual bool moveNext() = 0;
@@ -415,11 +413,14 @@ namespace Catch {
     struct IRunner;
     struct IGeneratorsForTest;
 
-    class StreamBufBase : public std::streambuf{};
+    class StreamBufBase : public std::streambuf {
+    public:
+        virtual ~StreamBufBase();
+    };
 
     struct IContext
     {
-        virtual ~IContext(){}
+        virtual ~IContext();
 
         virtual IResultCapture& getResultCapture() = 0;
         virtual IRunner& getRunner() = 0;
@@ -430,6 +431,7 @@ namespace Catch {
 
     struct IMutableContext : IContext
     {
+        virtual ~IMutableContext();
         virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
         virtual void setRunner( IRunner* runner ) = 0;
         virtual void setConfig( const IConfig* config ) = 0;
@@ -452,7 +454,7 @@ namespace Catch {
 
 namespace Catch {
     struct ITestCase {
-        virtual ~ITestCase(){}
+        virtual ~ITestCase();
         virtual void invoke () const = 0;
         virtual ITestCase* clone() const = 0;
         virtual bool operator == ( const ITestCase& other ) const = 0;
@@ -462,7 +464,7 @@ namespace Catch {
     class TestCaseInfo;
 
     struct ITestCaseRegistry {
-        virtual ~ITestCaseRegistry(){}
+        virtual ~ITestCaseRegistry();
         virtual const std::vector<TestCaseInfo>& getAllTests() const = 0;
         virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const = 0;
     };
@@ -538,7 +540,7 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_TESTCASE_NORETURN( Name, Desc ) \
-    static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )() ATTRIBUTE_NORETURN; \
+    static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )() CATCH_ATTRIBUTE_NORETURN; \
     namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ ), Name, Desc, CATCH_INTERNAL_LINEINFO ); }\
     static void INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ )()
 
@@ -797,7 +799,7 @@ namespace Catch {
                     const SourceLineInfo& lineInfo,
                     const char* macroName,
                    const char* message );
-        virtual ~ResultInfo();
+        ~ResultInfo();
 
         bool ok() const;
         ResultWas::OfType getResultType() const;
@@ -1210,7 +1212,7 @@ namespace Catch {
 
     struct IResultCapture {
 
-        virtual ~IResultCapture(){}
+        virtual ~IResultCapture();
 
         virtual void testEnded( const ResultInfo& result ) = 0;
         virtual bool sectionStarted(    const std::string& name,
@@ -1693,7 +1695,7 @@ namespace Catch {
     struct IExceptionTranslator;
 
     struct IRegistryHub {
-        virtual ~IRegistryHub(){}
+        virtual ~IRegistryHub();
 
         virtual const IReporterRegistry& getReporterRegistry() const = 0;
         virtual const ITestCaseRegistry& getTestCaseRegistry() const = 0;
@@ -1701,7 +1703,7 @@ namespace Catch {
     };
 
     struct IMutableRegistryHub {
-        virtual ~IMutableRegistryHub(){}
+        virtual ~IMutableRegistryHub();
         virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
         virtual void registerTest( const TestCaseInfo& testInfo ) = 0;
         virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
@@ -1718,12 +1720,12 @@ namespace Catch {
     typedef std::string(*exceptionTranslateFunction)();
 
     struct IExceptionTranslator {
-        virtual ~IExceptionTranslator(){}
+        virtual ~IExceptionTranslator();
         virtual std::string translate() const = 0;
     };
 
     struct IExceptionTranslatorRegistry {
-        virtual ~IExceptionTranslatorRegistry(){}
+        virtual ~IExceptionTranslatorRegistry();
 
         virtual std::string translateActiveException() const = 0;
     };
@@ -2061,7 +2063,7 @@ namespace Catch {
     class TestCaseInfo;
 
     struct IRunner {
-        virtual ~IRunner() {}
+        virtual ~IRunner();
         virtual void runAll( bool runHiddenTests = false ) = 0;
         virtual std::size_t runMatching( const std::string& rawTestSpec ) = 0;
         virtual Totals getTotals() const = 0;
@@ -2278,1770 +2280,1780 @@ return @ desc; \
 #endif
 
 #if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER )
+// #included from: internal/catch_impl.hpp
+
+// Collect all the implementation files together here
+// These are the equivalent of what would usually be cpp files
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wweak-vtables"
+
 // #included from: catch_runner.hpp
 #define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
 
-// #included from: internal/catch_commandline.hpp
-#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
+// #included from: reporters/catch_reporter_basic.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED
 
-// #included from: catch_config.hpp
-#define TWOBLUECUBES_CATCH_RUNNERCONFIG_HPP_INCLUDED
+// #included from: ../internal/catch_reporter_registrars.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
 
-#include <memory>
-#include <vector>
-#include <string>
-#include <iostream>
+namespace Catch {
+
+    template<typename T>
+    class ReporterRegistrar {
+
+        class ReporterFactory : public IReporterFactory {
+
+            virtual IReporter* create( const ReporterConfig& config ) const {
+                return new T( config );
+            }
+
+            virtual std::string getDescription() const {
+                return T::getDescription();
+            }
+        };
+
+    public:
+
+        ReporterRegistrar( const std::string& name ) {
+            getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
+        }
+    };
+}
+
+#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
+    Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
+
+// #included from: ../internal/catch_console_colour.hpp
+#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED
 
 namespace Catch {
 
-    struct Include { enum WhichResults {
-        FailedOnly,
-        SuccessfulResults
-    }; };
+    struct ConsoleColourImpl;
 
-    struct List{ enum What {
-        None = 0,
+    class TextColour : NonCopyable {
+    public:
 
-        Reports = 1,
-        Tests = 2,
-        All = 3,
+        enum Colours {
+            None,
 
-        WhatMask = 0xf,
+            FileName,
+            ResultError,
+            ResultSuccess,
 
-        AsText = 0x10,
-        AsXml = 0x11,
+            Error,
+            Success,
 
-        AsMask = 0xf0
-    }; };
+            OriginalExpression,
+            ReconstructedExpression
+        };
 
-    struct ConfigData {
-        ConfigData()
-        :   listSpec( List::None ),
-            shouldDebugBreak( false ),
-            includeWhichResults( Include::FailedOnly ),
-            cutoff( -1 ),
-            allowThrows( true )
-        {}
+        TextColour( Colours colour = None );
+        void set( Colours colour );
+        ~TextColour();
 
-        std::string reporter;
-        std::string outputFilename;
-        List::What listSpec;
-        std::vector<std::string> testSpecs;
-        bool shouldDebugBreak;
-        std::string stream;
-        Include::WhichResults includeWhichResults;
-        std::string name;
-        int cutoff;
-        bool allowThrows;
+    private:
+        ConsoleColourImpl* m_impl;
     };
 
-    class Config : public IConfig {
-    private:
-        Config( const Config& other );
-        Config& operator = ( const Config& other );
-    public:
+} // end namespace Catch
 
-        Config()
-        :   m_streambuf( NULL ),
-            m_os( std::cout.rdbuf() )
-        {}
+namespace Catch {
 
-        Config( const ConfigData& data )
-        :   m_data( data ),
-            m_streambuf( NULL ),
-            m_os( std::cout.rdbuf() )
+    struct pluralise {
+        pluralise( std::size_t count, const std::string& label )
+        :   m_count( count ),
+            m_label( label )
         {}
 
-        ~Config() {
-            m_os.rdbuf( std::cout.rdbuf() );
-            delete m_streambuf;
+        friend std::ostream& operator << ( std::ostream& os, const pluralise& pluraliser ) {
+            os << pluraliser.m_count << " " << pluraliser.m_label;
+            if( pluraliser.m_count != 1 )
+                os << "s";
+            return os;
         }
 
-        void setFilename( const std::string& filename ) {
-            m_data.outputFilename = filename;
-        }
+        std::size_t m_count;
+        std::string m_label;
+    };
 
-        bool testsSpecified() const {
-            return !m_data.testSpecs.empty();
-        }
+    class BasicReporter : public SharedImpl<IReporter> {
 
-        const std::vector<std::string>& getTestSpecs() const {
-            return m_data.testSpecs;
-        }
+        struct SpanInfo {
 
-        List::What getListSpec( void ) const {
-            return m_data.listSpec;
-        }
+            SpanInfo()
+            :   emitted( false )
+            {}
 
-        const std::string& getFilename() const {
-            return m_data.outputFilename ;
-        }
+            SpanInfo( const std::string& spanName )
+            :   name( spanName ),
+                emitted( false )
+            {}
 
-        List::What listWhat() const {
-            return static_cast<List::What>( m_data.listSpec & List::WhatMask );
-        }
+            SpanInfo( const SpanInfo& other )
+            :   name( other.name ),
+                emitted( other.emitted )
+            {}
 
-        List::What listAs() const {
-            return static_cast<List::What>( m_data.listSpec & List::AsMask );
+            std::string name;
+            bool emitted;
+        };
+
+    public:
+        BasicReporter( const ReporterConfig& config )
+        :   m_config( config ),
+            m_firstSectionInTestCase( true ),
+            m_aborted( false )
+        {}
+
+        virtual ~BasicReporter();
+
+        static std::string getDescription() {
+            return "Reports test results as lines of text";
         }
 
-        std::string getName() const {
-            return m_data.name;
+    private:
+
+        void ReportCounts( const std::string& label, const Counts& counts, const std::string& allPrefix = "All " ) {
+            if( counts.passed )
+                m_config.stream << counts.failed << " of " << counts.total() << " " << label << "s failed";
+            else
+                m_config.stream << ( counts.failed > 1 ? allPrefix : "" ) << pluralise( counts.failed, label ) << " failed";
         }
 
-        bool shouldDebugBreak() const {
-            return m_data.shouldDebugBreak;
+        void ReportCounts( const Totals& totals, const std::string& allPrefix = "All " ) {
+            if( totals.assertions.total() == 0 ) {
+                m_config.stream << "No tests ran";
+            }
+            else if( totals.assertions.failed ) {
+                TextColour colour( TextColour::ResultError );
+                ReportCounts( "test case", totals.testCases, allPrefix );
+                if( totals.testCases.failed > 0 ) {
+                    m_config.stream << " (";
+                    ReportCounts( "assertion", totals.assertions, allPrefix );
+                    m_config.stream << ")";
+                }
+            }
+            else {
+                TextColour colour( TextColour::ResultSuccess );
+                m_config.stream   << allPrefix << "tests passed ("
+                                    << pluralise( totals.assertions.passed, "assertion" ) << " in "
+                                    << pluralise( totals.testCases.passed, "test case" ) << ")";
+            }
         }
 
-        virtual std::ostream& stream() const {
-            return m_os;
+    private: // IReporter
+
+        virtual bool shouldRedirectStdout() const {
+            return false;
         }
 
-        void setStreamBuf( std::streambuf* buf ) {
-            m_os.rdbuf( buf ? buf : std::cout.rdbuf() );
+        virtual void StartTesting() {
+            m_testingSpan = SpanInfo();
         }
 
-        void useStream( const std::string& streamName ) {
-            std::streambuf* newBuf = createStreamBuf( streamName );
-            setStreamBuf( newBuf );
-            delete m_streambuf;
-            m_streambuf = newBuf;
+        virtual void Aborted() {
+            m_aborted = true;
         }
 
-        virtual bool includeSuccessfulResults() const {
-            return m_data.includeWhichResults == Include::SuccessfulResults;
+        virtual void EndTesting( const Totals& totals ) {
+            // Output the overall test results even if "Started Testing" was not emitted
+            if( m_aborted ) {
+                m_config.stream << "\n[Testing aborted. ";
+                ReportCounts( totals, "The first " );
+            }
+            else {
+                m_config.stream << "\n[Testing completed. ";
+                ReportCounts( totals );
+            }
+            m_config.stream << "]\n" << std::endl;
         }
 
-        int getCutoff() const {
-            return m_data.cutoff;
+        virtual void StartGroup( const std::string& groupName ) {
+            m_groupSpan = groupName;
         }
 
-        virtual bool allowThrows() const {
-            return m_data.allowThrows;
+        virtual void EndGroup( const std::string& groupName, const Totals& totals ) {
+            if( m_groupSpan.emitted && !groupName.empty() ) {
+                m_config.stream << "[End of group: '" << groupName << "'. ";
+                ReportCounts( totals );
+                m_config.stream << "]\n" << std::endl;
+                m_groupSpan = SpanInfo();
+            }
         }
 
-        ConfigData& data() {
-            return m_data;
+        virtual void StartTestCase( const TestCaseInfo& testInfo ) {
+            m_testSpan = testInfo.getName();
         }
 
-    private:
-        ConfigData m_data;
-
-        // !TBD Move these out of here
-        std::streambuf* m_streambuf;
-        mutable std::ostream m_os;
-    };
-
-} // end namespace Catch
+        virtual void StartSection( const std::string& sectionName, const std::string& ) {
+            m_sectionSpans.push_back( SpanInfo( sectionName ) );
+        }
 
-// #included from: catch_runner_impl.hpp
-#define TWOBLUECUBES_INTERNAL_CATCH_RUNNER_HPP_INCLUDED
+        virtual void EndSection( const std::string& sectionName, const Counts& assertions ) {
+            SpanInfo& sectionSpan = m_sectionSpans.back();
+            if( sectionSpan.emitted && !sectionSpan.name.empty() ) {
+                m_config.stream << "[End of section: '" << sectionName << "' ";
 
-// #included from: catch_running_test.hpp
-#define TWOBLUECUBES_INTERNAL_CATCH_RUNNING_TEST_HPP_INCLUDED
+                if( assertions.failed ) {
+                    TextColour colour( TextColour::ResultError );
+                    ReportCounts( "assertion", assertions);
+                }
+                else {
+                    TextColour colour( TextColour::ResultSuccess );
+                    m_config.stream   << ( assertions.passed > 1 ? "All " : "" )
+                                        << pluralise( assertions.passed, "assertion" ) << " passed" ;
+                }
+                m_config.stream << "]\n" << std::endl;
+            }
+            m_sectionSpans.pop_back();
+        }
 
-// #included from: catch_section_info.hpp
-#define TWOBLUECUBES_INTERNAL_CATCH_SECTION_INFO_HPP_INCLUDED
+        virtual void Result( const ResultInfo& resultInfo ) {
+            if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
+                return;
 
-#include <map>
-#include <string>
+            StartSpansLazily();
 
-namespace Catch {
+            if( !resultInfo.getFilename().empty() ) {
+                TextColour colour( TextColour::FileName );
+                m_config.stream << SourceLineInfo( resultInfo.getFilename(), resultInfo.getLine() );
+            }
 
-    class SectionInfo {
-    public:
+            if( resultInfo.hasExpression() ) {
+                TextColour colour( TextColour::OriginalExpression );
+                m_config.stream << resultInfo.getExpression();
+                if( resultInfo.ok() ) {
+                    TextColour successColour( TextColour::Success );
+                    m_config.stream << " succeeded";
+                }
+                else {
+                    TextColour errorColour( TextColour::Error );
+                    m_config.stream << " failed";
+                }
+            }
+            switch( resultInfo.getResultType() ) {
+                case ResultWas::ThrewException:
+                {
+                    TextColour colour( TextColour::Error );
+                    if( resultInfo.hasExpression() )
+                        m_config.stream << " with unexpected";
+                    else
+                        m_config.stream << "Unexpected";
+                    m_config.stream << " exception with message: '" << resultInfo.getMessage() << "'";
+                }
+                    break;
+                case ResultWas::DidntThrowException:
+                {
+                    TextColour colour( TextColour::Error );
+                    if( resultInfo.hasExpression() )
+                        m_config.stream << " because no exception was thrown where one was expected";
+                    else
+                        m_config.stream << "No exception thrown where one was expected";
+                }
+                    break;
+                case ResultWas::Info:
+                    streamVariableLengthText( "info", resultInfo.getMessage() );
+                    break;
+                case ResultWas::Warning:
+                    m_config.stream << "warning:\n'" << resultInfo.getMessage() << "'";
+                    break;
+                case ResultWas::ExplicitFailure:
+                {
+                    TextColour colour( TextColour::Error );
+                    m_config.stream << "failed with message: '" << resultInfo.getMessage() << "'";
+                }
+                    break;
+                case ResultWas::Unknown: // These cases are here to prevent compiler warnings
+                case ResultWas::Ok:
+                case ResultWas::FailureBit:
+                case ResultWas::ExpressionFailed:
+                case ResultWas::Exception:
+                    if( !resultInfo.hasExpression() ) {
+                        if( resultInfo.ok() ) {
+                            TextColour colour( TextColour::Success );
+                            m_config.stream << " succeeded";
+                        }
+                        else {
+                            TextColour colour( TextColour::Error );
+                            m_config.stream << " failed";
+                        }
+                    }
+                    break;
+            }
 
-        enum Status {
-            Root,
-            Unknown,
-            Branch,
-            TestedBranch,
-            TestedLeaf
-        };
+            if( resultInfo.hasExpandedExpression() ) {
+                m_config.stream << " for: ";
+                TextColour colour( TextColour::ReconstructedExpression );
+                m_config.stream << resultInfo.getExpandedExpression();
+            }
+            m_config.stream << std::endl;
+        }
 
-        SectionInfo( SectionInfo* parent )
-        :   m_status( Unknown ),
-            m_parent( parent )
-        {}
+        virtual void EndTestCase(   const TestCaseInfo& testInfo,
+                                    const Totals& totals,
+                                    const std::string& stdOut,
+                                    const std::string& stdErr ) {
+            if( !stdOut.empty() ) {
+                StartSpansLazily();
+                streamVariableLengthText( "stdout", stdOut );
+            }
 
-        SectionInfo()
-        :   m_status( Root ),
-            m_parent( NULL )
-        {}
+            if( !stdErr.empty() ) {
+                StartSpansLazily();
+                streamVariableLengthText( "stderr", stdErr );
+            }
 
-        ~SectionInfo() {
-            deleteAllValues( m_subSections );
+            if( m_testSpan.emitted ) {
+                m_config.stream << "[Finished: '" << testInfo.getName() << "' ";
+                ReportCounts( totals );
+                m_config.stream << "]" << std::endl;
+            }
         }
 
-        bool shouldRun() const {
-            return m_status < TestedBranch;
-        }
+    private: // helpers
 
-        bool ran() {
-            if( m_status < Branch ) {
-                m_status = TestedLeaf;
-                return true;
+        void StartSpansLazily() {
+            if( !m_testingSpan.emitted ) {
+                if( m_config.name.empty() )
+                    m_config.stream << "[Started testing]" << std::endl;
+                else
+                    m_config.stream << "[Started testing: " << m_config.name << "]" << std::endl;
+                m_testingSpan.emitted = true;
             }
-            return false;
-        }
 
-        void ranToCompletion() {
-            if( m_status == Branch && !hasUntestedSections() )
-                m_status = TestedBranch;
-        }
-
-        SectionInfo* findSubSection( const std::string& name ) {
-            std::map<std::string, SectionInfo*>::const_iterator it = m_subSections.find( name );
-            return it != m_subSections.end()
-                        ? it->second
-                        : NULL;
-        }
+            if( !m_groupSpan.emitted && !m_groupSpan.name.empty() ) {
+                m_config.stream << "[Started group: '" << m_groupSpan.name << "']" << std::endl;
+                m_groupSpan.emitted = true;
+            }
 
-        SectionInfo* addSubSection( const std::string& name ) {
-            SectionInfo* subSection = new SectionInfo( this );
-            m_subSections.insert( std::make_pair( name, subSection ) );
-            m_status = Branch;
-            return subSection;
-        }
+            if( !m_testSpan.emitted ) {
+                m_config.stream << std::endl << "[Running: " << m_testSpan.name << "]" << std::endl;
+                m_testSpan.emitted = true;
+            }
 
-        SectionInfo* getParent() {
-            return m_parent;
+            if( !m_sectionSpans.empty() ) {
+                SpanInfo& sectionSpan = m_sectionSpans.back();
+                if( !sectionSpan.emitted && !sectionSpan.name.empty() ) {
+                    if( m_firstSectionInTestCase ) {
+                        m_config.stream << "\n";
+                        m_firstSectionInTestCase = false;
+                    }
+                    std::vector<SpanInfo>::iterator it = m_sectionSpans.begin();
+                    std::vector<SpanInfo>::iterator itEnd = m_sectionSpans.end();
+                    for(; it != itEnd; ++it ) {
+                        SpanInfo& prevSpan = *it;
+                        if( !prevSpan.emitted && !prevSpan.name.empty() ) {
+                            m_config.stream << "[Started section: '" << prevSpan.name << "']" << std::endl;
+                            prevSpan.emitted = true;
+                        }
+                    }
+                }
+            }
         }
 
-        bool hasUntestedSections() const {
-            if( m_status == Unknown )
-                return true;
-
-            std::map<std::string, SectionInfo*>::const_iterator it = m_subSections.begin();
-            std::map<std::string, SectionInfo*>::const_iterator itEnd = m_subSections.end();
-            for(; it != itEnd; ++it ) {
-                if( it->second->hasUntestedSections() )
-                    return true;
+        void streamVariableLengthText( const std::string& prefix, const std::string& text ) {
+            std::string trimmed = trim( text );
+            if( trimmed.find_first_of( "\r\n" ) == std::string::npos ) {
+                m_config.stream << "[" << prefix << ": " << trimmed << "]\n";
+            }
+            else {
+                m_config.stream << "\n[" << prefix << "] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << trimmed
+                << "\n[end of " << prefix << "] <<<<<<<<<<<<<<<<<<<<<<<<\n";
             }
-            return false;
         }
 
     private:
-        Status m_status;
-        std::map<std::string, SectionInfo*> m_subSections;
-        SectionInfo* m_parent;
-    };
-}
+        ReporterConfig m_config;
+        bool m_firstSectionInTestCase;
 
-namespace Catch {
+        SpanInfo m_testingSpan;
+        SpanInfo m_groupSpan;
+        SpanInfo m_testSpan;
+        std::vector<SpanInfo> m_sectionSpans;
+        bool m_aborted;
+    };
 
-    class RunningTest {
+} // end namespace Catch
 
-        enum RunStatus {
-            NothingRun,
-            EncounteredASection,
-            RanAtLeastOneSection,
-            RanToCompletionWithSections,
-            RanToCompletionWithNoSections
-        };
+// #included from: reporters/catch_reporter_xml.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
 
-    public:
-        explicit RunningTest( const TestCaseInfo* info = NULL )
-        :   m_info( info ),
-            m_runStatus( RanAtLeastOneSection ),
-            m_currentSection( &m_rootSection ),
-            m_changed( false )
-        {}
+// #included from: ../internal/catch_xmlwriter.hpp
+#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
 
-        bool wasSectionSeen() const {
-            return  m_runStatus == RanAtLeastOneSection ||
-                    m_runStatus == RanToCompletionWithSections;
-        }
+#include <sstream>
+#include <string>
+#include <vector>
 
-        void reset() {
-            m_runStatus = NothingRun;
-            m_changed = false;
-            m_lastSectionToRun = NULL;
-        }
+namespace Catch {
 
-        void ranToCompletion() {
-            if( m_runStatus == RanAtLeastOneSection ||
-                m_runStatus == EncounteredASection ) {
-                m_runStatus = RanToCompletionWithSections;
-                if( m_lastSectionToRun ) {
-                    m_lastSectionToRun->ranToCompletion();
-                    m_changed = true;
-                }
-            }
-            else {
-                m_runStatus = RanToCompletionWithNoSections;
-            }
-        }
+    class XmlWriter {
+    public:
 
-        bool addSection( const std::string& name ) {
-            if( m_runStatus == NothingRun )
-                m_runStatus = EncounteredASection;
+        class ScopedElement {
+        public:
+            ScopedElement( XmlWriter* writer )
+            :   m_writer( writer )
+            {}
 
-            SectionInfo* thisSection = m_currentSection->findSubSection( name );
-            if( !thisSection ) {
-                thisSection = m_currentSection->addSubSection( name );
-                m_changed = true;
+            ScopedElement( const ScopedElement& other )
+            :   m_writer( other.m_writer ){
+                other.m_writer = NULL;
             }
 
-            if( !wasSectionSeen() && thisSection->shouldRun() ) {
-                m_currentSection = thisSection;
-                m_lastSectionToRun = NULL;
-                return true;
+            ~ScopedElement() {
+                if( m_writer )
+                    m_writer->endElement();
             }
-            return false;
-        }
 
-        void endSection( const std::string& ) {
-            if( m_currentSection->ran() ) {
-                m_runStatus = RanAtLeastOneSection;
-                m_changed = true;
+            ScopedElement& writeText( const std::string& text ) {
+                m_writer->writeText( text );
+                return *this;
             }
-            else if( m_runStatus == EncounteredASection ) {
-                m_runStatus = RanAtLeastOneSection;
-                m_lastSectionToRun = m_currentSection;
+
+            template<typename T>
+            ScopedElement& writeAttribute( const std::string& name, const T& attribute ) {
+                m_writer->writeAttribute( name, attribute );
+                return *this;
             }
-            m_currentSection = m_currentSection->getParent();
+
+        private:
+            mutable XmlWriter* m_writer;
+        };
+
+        XmlWriter()
+        :   m_tagIsOpen( false ),
+            m_needsNewline( false ),
+            m_os( &std::cout )
+        {}
+
+        XmlWriter( std::ostream& os )
+        :   m_tagIsOpen( false ),
+            m_needsNewline( false ),
+            m_os( &os )
+        {}
+
+        ~XmlWriter() {
+            while( !m_tags.empty() )
+                endElement();
         }
 
-        const TestCaseInfo& getTestCaseInfo() const {
-            return *m_info;
+        XmlWriter& operator = ( const XmlWriter& other ) {
+            XmlWriter temp( other );
+            swap( temp );
+            return *this;
         }
 
-        bool hasUntestedSections() const {
-            return  m_runStatus == RanAtLeastOneSection ||
-                    ( m_rootSection.hasUntestedSections() && m_changed );
+        void swap( XmlWriter& other ) {
+            std::swap( m_tagIsOpen, other.m_tagIsOpen );
+            std::swap( m_needsNewline, other.m_needsNewline );
+            std::swap( m_tags, other.m_tags );
+            std::swap( m_indent, other.m_indent );
+            std::swap( m_os, other.m_os );
         }
 
-    private:
-        const TestCaseInfo* m_info;
-        RunStatus m_runStatus;
-        SectionInfo m_rootSection;
-        SectionInfo* m_currentSection;
-        SectionInfo* m_lastSectionToRun;
-        bool m_changed;
-    };
-}
+        XmlWriter& startElement( const std::string& name ) {
+            ensureTagClosed();
+            newlineIfNecessary();
+            stream() << m_indent << "<" << name;
+            m_tags.push_back( name );
+            m_indent += "  ";
+            m_tagIsOpen = true;
+            return *this;
+        }
 
-#include <set>
-#include <string>
+        ScopedElement scopedElement( const std::string& name ) {
+            ScopedElement scoped( this );
+            startElement( name );
+            return scoped;
+        }
 
-namespace Catch {
+        XmlWriter& endElement() {
+            newlineIfNecessary();
+            m_indent = m_indent.substr( 0, m_indent.size()-2 );
+            if( m_tagIsOpen ) {
+                stream() << "/>\n";
+                m_tagIsOpen = false;
+            }
+            else {
+                stream() << m_indent << "</" << m_tags.back() << ">\n";
+            }
+            m_tags.pop_back();
+            return *this;
+        }
 
-    class StreamRedirect {
+        XmlWriter& writeAttribute( const std::string& name, const std::string& attribute ) {
+            if( !name.empty() && !attribute.empty() ) {
+                stream() << " " << name << "=\"";
+                writeEncodedText( attribute );
+                stream() << "\"";
+            }
+            return *this;
+        }
 
-    public:
-        StreamRedirect( std::ostream& stream, std::string& targetString )
-        :   m_stream( stream ),
-            m_prevBuf( stream.rdbuf() ),
-            m_targetString( targetString )
-        {
-            stream.rdbuf( m_oss.rdbuf() );
+        XmlWriter& writeAttribute( const std::string& name, bool attribute ) {
+            stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
+            return *this;
         }
 
-        ~StreamRedirect() {
-            m_targetString += m_oss.str();
-            m_stream.rdbuf( m_prevBuf );
+        template<typename T>
+        XmlWriter& writeAttribute( const std::string& name, const T& attribute ) {
+            if( !name.empty() )
+                stream() << " " << name << "=\"" << attribute << "\"";
+            return *this;
         }
 
-    private:
-        std::ostream& m_stream;
-        std::streambuf* m_prevBuf;
-        std::ostringstream m_oss;
-        std::string& m_targetString;
-    };
-
-    ///////////////////////////////////////////////////////////////////////////
+        XmlWriter& writeText( const std::string& text ) {
+            if( !text.empty() ){
+                bool tagWasOpen = m_tagIsOpen;
+                ensureTagClosed();
+                if( tagWasOpen )
+                    stream() << m_indent;
+                writeEncodedText( text );
+                m_needsNewline = true;
+            }
+            return *this;
+        }
 
-    class Runner : public IResultCapture, public IRunner {
+        XmlWriter& writeComment( const std::string& text ) {
+            ensureTagClosed();
+            stream() << m_indent << "<!--" << text << "-->";
+            m_needsNewline = true;
+            return *this;
+        }
 
-        Runner( const Runner& );
-        void operator =( const Runner& );
+        XmlWriter& writeBlankLine() {
+            ensureTagClosed();
+            stream() << "\n";
+            return *this;
+        }
 
-    public:
+    private:
 
-        explicit Runner( Config& config, const Ptr<IReporter>& reporter )
-        :   m_context( getCurrentMutableContext() ),
-            m_runningTest( NULL ),
-            m_config( config ),
-            m_reporter( reporter ),
-            m_prevRunner( &m_context.getRunner() ),
-            m_prevResultCapture( &m_context.getResultCapture() ),
-            m_prevConfig( m_context.getConfig() )
-        {
-            m_context.setRunner( this );
-            m_context.setConfig( &m_config );
-            m_context.setResultCapture( this );
-            m_reporter->StartTesting();
+        std::ostream& stream() {
+            return *m_os;
         }
 
-        ~Runner() {
-            m_reporter->EndTesting( m_totals );
-            m_context.setRunner( m_prevRunner );
-            m_context.setConfig( NULL );
-            m_context.setResultCapture( m_prevResultCapture );
-            m_context.setConfig( m_prevConfig );
+        void ensureTagClosed() {
+            if( m_tagIsOpen ) {
+                stream() << ">\n";
+                m_tagIsOpen = false;
+            }
         }
 
-        virtual void runAll( bool runHiddenTests = false ) {
-            m_reporter->StartGroup( "" );
-            const std::vector<TestCaseInfo>& allTests = getRegistryHub().getTestCaseRegistry().getAllTests();
-            for( std::size_t i=0; i < allTests.size(); ++i ) {
-                if( runHiddenTests || !allTests[i].isHidden() ) {
-                    if( aborting() ) {
-                        m_reporter->Aborted();
-                        break;
-                    }
-                    runTest( allTests[i] );
-                }
+        void newlineIfNecessary() {
+            if( m_needsNewline ) {
+                stream() << "\n";
+                m_needsNewline = false;
             }
-            m_reporter->EndGroup( "", getTotals() );
         }
 
-        virtual std::size_t runMatching( const std::string& rawTestSpec ) {
-
-            Totals prevTotals = getTotals();
-            m_reporter->StartGroup( rawTestSpec );
-
-            TestSpec testSpec( rawTestSpec );
+        void writeEncodedText( const std::string& text ) {
+            static const char* charsToEncode = "<&\"";
+            std::string mtext = text;
+            std::string::size_type pos = mtext.find_first_of( charsToEncode );
+            while( pos != std::string::npos ) {
+                stream() << mtext.substr( 0, pos );
 
-            const std::vector<TestCaseInfo>& allTests = getRegistryHub().getTestCaseRegistry().getAllTests();
-            std::size_t testsRun = 0;
-            for( std::size_t i=0; i < allTests.size(); ++i ) {
-                if( testSpec.matches( allTests[i].getName() ) ) {
-                    if( aborting() ) {
-                        m_reporter->Aborted();
+                switch( mtext[pos] ) {
+                    case '<':
+                        stream() << "&lt;";
+                        break;
+                    case '&':
+                        stream() << "&amp;";
+                        break;
+                    case '\"':
+                        stream() << "&quot;";
                         break;
-                    }
-                    runTest( allTests[i] );
-                    testsRun++;
                 }
+                mtext = mtext.substr( pos+1 );
+                pos = mtext.find_first_of( charsToEncode );
             }
-            m_reporter->EndGroup( rawTestSpec, getTotals() - prevTotals );
-            return testsRun;
+            stream() << mtext;
         }
 
-        void runTest( const TestCaseInfo& testInfo ) {
-            Totals prevTotals = m_totals;
-
-            std::string redirectedCout;
-            std::string redirectedCerr;
-
-            m_reporter->StartTestCase( testInfo );
+        bool m_tagIsOpen;
+        bool m_needsNewline;
+        std::vector<std::string> m_tags;
+        std::string m_indent;
+        std::ostream* m_os;
+    };
 
-            m_runningTest = new RunningTest( &testInfo );
+}
+namespace Catch {
+    class XmlReporter : public SharedImpl<IReporter> {
+    public:
+        XmlReporter( const ReporterConfig& config ) : m_config( config ) {}
 
-            do {
-                do {
-//                    m_reporter->StartGroup( "test case run" );
-                    m_currentResult.setLineInfo( m_runningTest->getTestCaseInfo().getLineInfo() );
-                    runCurrentTest( redirectedCout, redirectedCerr );
-//                    m_reporter->EndGroup( "test case run", m_totals.delta( prevTotals ) );
-                }
-                while( m_runningTest->hasUntestedSections() && !aborting() );
-            }
-            while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
+        static std::string getDescription() {
+            return "Reports test results as an XML document";
+        }
+        virtual ~XmlReporter();
 
-            delete m_runningTest;
-            m_runningTest = NULL;
+    private: // IReporter
 
-            Totals deltaTotals = m_totals.delta( prevTotals );
-            m_totals.testCases += deltaTotals.testCases;
-            m_reporter->EndTestCase( testInfo, deltaTotals, redirectedCout, redirectedCerr );
+        virtual bool shouldRedirectStdout() const {
+            return true;
         }
 
-        virtual Totals getTotals() const {
-            return m_totals;
+        virtual void StartTesting() {
+            m_xml = XmlWriter( m_config.stream );
+            m_xml.startElement( "Catch" );
+            if( !m_config.name.empty() )
+                m_xml.writeAttribute( "name", m_config.name );
         }
 
-        const Config& config() const {
-            return m_config;
+        virtual void EndTesting( const Totals& totals ) {
+            m_xml.scopedElement( "OverallResults" )
+                .writeAttribute( "successes", totals.assertions.passed )
+                .writeAttribute( "failures", totals.assertions.failed );
+            m_xml.endElement();
         }
 
-    private: // IResultCapture
+        virtual void StartGroup( const std::string& groupName ) {
+            m_xml.startElement( "Group" )
+                .writeAttribute( "name", groupName );
+        }
 
-        virtual ResultAction::Value acceptResult( bool result ) {
-            return acceptResult( result ? ResultWas::Ok : ResultWas::ExpressionFailed );
+        virtual void EndGroup( const std::string&, const Totals& totals ) {
+            m_xml.scopedElement( "OverallResults" )
+                .writeAttribute( "successes", totals.assertions.passed )
+                .writeAttribute( "failures", totals.assertions.failed );
+            m_xml.endElement();
         }
 
-        virtual ResultAction::Value acceptResult( ResultWas::OfType result ) {
-            m_currentResult.setResultType( result );
-            return actOnCurrentResult();
+        virtual void StartSection( const std::string& sectionName, const std::string& description ) {
+            m_xml.startElement( "Section" )
+                .writeAttribute( "name", sectionName )
+                .writeAttribute( "description", description );
         }
 
-        virtual ResultAction::Value acceptExpression( const ResultInfoBuilder& resultInfo ) {
-            m_currentResult = resultInfo;
-            return actOnCurrentResult();
+        virtual void EndSection( const std::string& /*sectionName*/, const Counts& assertions ) {
+            m_xml.scopedElement( "OverallResults" )
+                .writeAttribute( "successes", assertions.passed )
+                .writeAttribute( "failures", assertions.failed );
+            m_xml.endElement();
         }
 
-        virtual void acceptMessage( const std::string& msg ) {
-            m_currentResult.setMessage( msg );
+        virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
+            m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.getName() );
+            m_currentTestSuccess = true;
         }
 
-        virtual void testEnded( const ResultInfo& result ) {
-            if( result.getResultType() == ResultWas::Ok ) {
-                m_totals.assertions.passed++;
+        virtual void Result( const Catch::ResultInfo& resultInfo ) {
+            if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
+                return;
+
+            if( resultInfo.hasExpression() ) {
+                m_xml.startElement( "Expression" )
+                    .writeAttribute( "success", resultInfo.ok() )
+                    .writeAttribute( "filename", resultInfo.getFilename() )
+                    .writeAttribute( "line", resultInfo.getLine() );
+
+                m_xml.scopedElement( "Original" )
+                    .writeText( resultInfo.getExpression() );
+                m_xml.scopedElement( "Expanded" )
+                    .writeText( resultInfo.getExpandedExpression() );
+                m_currentTestSuccess &= resultInfo.ok();
             }
-            else if( !result.ok() ) {
-                m_totals.assertions.failed++;
 
-                std::vector<ResultInfo>::const_iterator it = m_info.begin();
-                std::vector<ResultInfo>::const_iterator itEnd = m_info.end();
-                for(; it != itEnd; ++it )
-                    m_reporter->Result( *it );
-                m_info.clear();
+            switch( resultInfo.getResultType() ) {
+                case ResultWas::ThrewException:
+                    m_xml.scopedElement( "Exception" )
+                        .writeAttribute( "filename", resultInfo.getFilename() )
+                        .writeAttribute( "line", resultInfo.getLine() )
+                        .writeText( resultInfo.getMessage() );
+                    m_currentTestSuccess = false;
+                    break;
+                case ResultWas::Info:
+                    m_xml.scopedElement( "Info" )
+                        .writeText( resultInfo.getMessage() );
+                    break;
+                case ResultWas::Warning:
+                    m_xml.scopedElement( "Warning" )
+                        .writeText( resultInfo.getMessage() );
+                    break;
+                case ResultWas::ExplicitFailure:
+                    m_xml.scopedElement( "Failure" )
+                        .writeText( resultInfo.getMessage() );
+                    m_currentTestSuccess = false;
+                    break;
+                case ResultWas::Unknown:
+                case ResultWas::Ok:
+                case ResultWas::FailureBit:
+                case ResultWas::ExpressionFailed:
+                case ResultWas::Exception:
+                case ResultWas::DidntThrowException:
+                    break;
             }
-
-            if( result.getResultType() == ResultWas::Info )
-                m_info.push_back( result );
-            else
-                m_reporter->Result( result );
+            if( resultInfo.hasExpression() )
+                m_xml.endElement();
         }
 
-        virtual bool sectionStarted (
-            const std::string& name,
-            const std::string& description,
-            const SourceLineInfo& lineInfo,
-            Counts& assertions
-        )
-        {
-            std::ostringstream oss;
-            oss << name << "@" << lineInfo;
-
-            if( !m_runningTest->addSection( oss.str() ) )
-                return false;
-
-            m_currentResult.setLineInfo( lineInfo );
-            m_reporter->StartSection( name, description );
-            assertions = m_totals.assertions;
-
-            return true;
+        virtual void Aborted() {
+            // !TBD
         }
 
-        virtual void sectionEnded( const std::string& name, const Counts& prevAssertions ) {
-            m_runningTest->endSection( name );
-            m_reporter->EndSection( name, m_totals.assertions - prevAssertions );
+        virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string&, const std::string& ) {
+            m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess );
+            m_xml.endElement();
         }
 
-        virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
-            m_scopedInfos.push_back( scopedInfo );
-        }
+    private:
+        ReporterConfig m_config;
+        bool m_currentTestSuccess;
+        XmlWriter m_xml;
+    };
 
-        virtual void popScopedInfo( ScopedInfo* scopedInfo ) {
-            if( m_scopedInfos.back() == scopedInfo )
-                m_scopedInfos.pop_back();
-        }
+} // end namespace Catch
 
-        virtual bool shouldDebugBreak() const {
-            return m_config.shouldDebugBreak();
-        }
+// #included from: reporters/catch_reporter_junit.hpp
+#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
 
-        virtual std::string getCurrentTestName() const {
-            return m_runningTest
-                ? m_runningTest->getTestCaseInfo().getName()
-                : "";
-        }
+namespace Catch {
 
-        virtual const ResultInfo* getLastResult() const {
-            return &m_lastResult;
-        }
+    class JunitReporter : public SharedImpl<IReporter> {
 
-    private:
+        struct TestStats {
+            std::string m_element;
+            std::string m_resultType;
+            std::string m_message;
+            std::string m_content;
+        };
 
-        bool aborting() const {
-            return m_totals.assertions.failed == static_cast<std::size_t>( m_config.getCutoff() );
-        }
+        struct TestCaseStats {
 
-        ResultAction::Value actOnCurrentResult() {
-            testEnded( m_currentResult );
-            m_lastResult = m_currentResult;
+            TestCaseStats( const std::string& name = std::string() ) :m_name( name ){}
 
-            m_currentResult = ResultInfoBuilder();
+            double      m_timeInSeconds;
+            std::string m_status;
+            std::string m_className;
+            std::string m_name;
+            std::vector<TestStats> m_testStats;
+        };
 
-            ResultAction::Value action = ResultAction::None;
+        struct Stats {
 
-            if( !m_lastResult.ok() ) {
-                action = ResultAction::Failed;
-                if( shouldDebugBreak() )
-                    action = (ResultAction::Value)( action | ResultAction::Debug );
-                if( aborting() )
-                    action = (ResultAction::Value)( action | ResultAction::Abort );
-            }
-            return action;
-        }
+            Stats( const std::string& name = std::string() )
+            :   m_testsCount( 0 ),
+                m_failuresCount( 0 ),
+                m_disabledCount( 0 ),
+                m_errorsCount( 0 ),
+                m_timeInSeconds( 0 ),
+                m_name( name )
+            {}
 
-        void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
-            try {
-                m_runningTest->reset();
-                if( m_reporter->shouldRedirectStdout() ) {
-                    StreamRedirect coutRedir( std::cout, redirectedCout );
-                    StreamRedirect cerrRedir( std::cerr, redirectedCerr );
-                    m_runningTest->getTestCaseInfo().invoke();
-                }
-                else {
-                    m_runningTest->getTestCaseInfo().invoke();
-                }
-                m_runningTest->ranToCompletion();
-            }
-            catch( TestFailureException& ) {
-                // This just means the test was aborted due to failure
-            }
-            catch(...) {
-                acceptMessage( getRegistryHub().getExceptionTranslatorRegistry().translateActiveException() );
-                acceptResult( ResultWas::ThrewException );
-            }
-            m_info.clear();
-        }
+            std::size_t m_testsCount;
+            std::size_t m_failuresCount;
+            std::size_t m_disabledCount;
+            std::size_t m_errorsCount;
+            double      m_timeInSeconds;
+            std::string m_name;
 
-    private:
-        IMutableContext& m_context;
-        RunningTest* m_runningTest;
-        ResultInfoBuilder m_currentResult;
-        ResultInfo m_lastResult;
+            std::vector<TestCaseStats> m_testCaseStats;
+        };
 
-        const Config& m_config;
-        Totals m_totals;
-        Ptr<IReporter> m_reporter;
-        std::vector<ScopedInfo*> m_scopedInfos;
-        std::vector<ResultInfo> m_info;
-        IRunner* m_prevRunner;
-        IResultCapture* m_prevResultCapture;
-        const IConfig* m_prevConfig;
-    };
+    public:
+        JunitReporter( const ReporterConfig& config )
+        :   m_config( config ),
+            m_testSuiteStats( "AllTests" ),
+            m_currentStats( &m_testSuiteStats )
+        {}
+        virtual ~JunitReporter();
 
-} // end namespace Catch
+        static std::string getDescription() {
+            return "Reports test results in an XML format that looks like Ant's junitreport target";
+        }
 
-namespace Catch {
+    private: // IReporter
 
-    class Command {
-    public:
-        Command(){}
+        virtual bool shouldRedirectStdout() const {
+            return true;
+        }
 
-        explicit Command( const std::string& name ) : m_name( name ) {}
+        virtual void StartTesting(){}
 
-        Command& operator += ( const std::string& arg ) {
-            m_args.push_back( arg );
-            return *this;
-        }
-        Command& operator += ( const Command& other ) {
-            std::copy( other.m_args.begin(), other.m_args.end(), std::back_inserter( m_args ) );
-            if( m_name.empty() )
-                m_name = other.m_name;
-            return *this;
-        }
-        Command operator + ( const Command& other ) {
-            Command newCommand( *this );
-            newCommand += other;
-            return newCommand;
+        virtual void StartGroup( const std::string& groupName ) {
+            m_statsForSuites.push_back( Stats( groupName ) );
+            m_currentStats = &m_statsForSuites.back();
         }
 
-        operator SafeBool::type() const {
-            return SafeBool::makeSafe( !m_name.empty() );
+        virtual void EndGroup( const std::string&, const Totals& totals ) {
+            m_currentStats->m_testsCount = totals.assertions.total();
+            m_currentStats = &m_testSuiteStats;
         }
 
-        std::string name() const { return m_name; }
-        std::string operator[]( std::size_t i ) const { return m_args[i]; }
-        std::size_t argsCount() const { return m_args.size(); }
-
-        void raiseError( const std::string& message ) const {
-            std::ostringstream oss;
-            oss << "Error while parsing " << m_name << ". " << message << ".";
-            if( m_args.size() > 0 )
-                oss << " Arguments where:";
-            for( std::size_t i = 0; i < m_args.size(); ++i )
-                oss << " " << m_args[i];
-            throw std::domain_error( oss.str() );
-        }
+        virtual void StartSection( const std::string&, const std::string& ){}
 
-    private:
+        virtual void EndSection( const std::string&, const Counts& ){}
 
-        std::string m_name;
-        std::vector<std::string> m_args;
-    };
+        virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
+            m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getName() ) );
+        }
 
-    class CommandParser {
-    public:
-        CommandParser( int argc, char const * const * argv ) : m_argc( static_cast<std::size_t>( argc ) ), m_argv( argv ) {}
+        virtual void Result( const Catch::ResultInfo& resultInfo ) {
+            if( resultInfo.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults ) {
+                TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
+                TestStats stats;
+                std::ostringstream oss;
+                if( !resultInfo.getMessage().empty() )
+                    oss << resultInfo.getMessage() << " at ";
+                oss << SourceLineInfo( resultInfo.getFilename(), resultInfo.getLine() );
+                stats.m_content = oss.str();
+                stats.m_message = resultInfo.getExpandedExpression();
+                stats.m_resultType = resultInfo.getTestMacroName();
 
-        Command find( const std::string& arg1,  const std::string& arg2, const std::string& arg3 ) const {
-            return find( arg1 ) + find( arg2 ) + find( arg3 );
+                switch( resultInfo.getResultType() ) {
+                    case ResultWas::ThrewException:
+                        stats.m_element = "error";
+                        m_currentStats->m_errorsCount++;
+                        break;
+                    case ResultWas::Info:
+                        stats.m_element = "info"; // !TBD ?
+                        break;
+                    case ResultWas::Warning:
+                        stats.m_element = "warning"; // !TBD ?
+                        break;
+                    case ResultWas::ExplicitFailure:
+                        stats.m_element = "failure";
+                        m_currentStats->m_failuresCount++;
+                        break;
+                    case ResultWas::ExpressionFailed:
+                        stats.m_element = "failure";
+                        m_currentStats->m_failuresCount++;
+                        break;
+                    case ResultWas::Ok:
+                        stats.m_element = "success";
+                        break;
+                    case ResultWas::Unknown:
+                    case ResultWas::FailureBit:
+                    case ResultWas::Exception:
+                    case ResultWas::DidntThrowException:
+                        break;
+                }
+                testCaseStats.m_testStats.push_back( stats );
+            }
         }
 
-        Command find( const std::string& shortArg, const std::string& longArg ) const {
-            return find( shortArg ) + find( longArg );
-        }
-        Command find( const std::string& arg ) const {
-            for( std::size_t i = 0; i < m_argc; ++i  )
-                if( m_argv[i] == arg )
-                    return getArgs( i );
-            return Command();
+        virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string& stdOut, const std::string& stdErr ) {
+            if( !stdOut.empty() )
+                m_stdOut << stdOut << "\n";
+            if( !stdErr.empty() )
+                m_stdErr << stdErr << "\n";
         }
 
-    private:
-        Command getArgs( std::size_t from ) const {
-            Command command( m_argv[from] );
-            for( std::size_t i = from+1; i < m_argc && m_argv[i][0] != '-'; ++i  )
-                command += m_argv[i];
-            return command;
+        virtual void Aborted() {
+            // !TBD
         }
 
-        std::size_t m_argc;
-        char const * const * m_argv;
-    };
+        virtual void EndTesting( const Totals& ) {
+            std::ostream& str = m_config.stream;
+            {
+                XmlWriter xml( str );
 
-    inline void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
+                if( m_statsForSuites.size() > 0 )
+                    xml.startElement( "testsuites" );
 
-        if( Command cmd = parser.find( "-l", "--list" ) ) {
-            if( cmd.argsCount() > 2 )
-                cmd.raiseError( "Expected upto 2 arguments" );
+                std::vector<Stats>::const_iterator it = m_statsForSuites.begin();
+                std::vector<Stats>::const_iterator itEnd = m_statsForSuites.end();
 
-            List::What listSpec = List::All;
-            if( cmd.argsCount() >= 1 ) {
-                if( cmd[0] == "tests" )
-                    config.listSpec = List::Tests;
-                else if( cmd[0] == "reporters" )
-                    config.listSpec = List::Reports;
-                else
-                    cmd.raiseError( "Expected [tests] or [reporters]" );
-            }
-            if( cmd.argsCount() >= 2 ) {
-                if( cmd[1] == "xml" )
-                    config.listSpec = static_cast<List::What>( listSpec | List::AsXml );
-                else if( cmd[1] == "text" )
-                    config.listSpec = static_cast<List::What>( listSpec | List::AsText );
-                else
-                    cmd.raiseError( "Expected [xml] or [text]" );
-            }
-        }
+                for(; it != itEnd; ++it ) {
+                    XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
+                    xml.writeAttribute( "name", it->m_name );
+                    xml.writeAttribute( "errors", it->m_errorsCount );
+                    xml.writeAttribute( "failures", it->m_failuresCount );
+                    xml.writeAttribute( "tests", it->m_testsCount );
+                    xml.writeAttribute( "hostname", "tbd" );
+                    xml.writeAttribute( "time", "tbd" );
+                    xml.writeAttribute( "timestamp", "tbd" );
 
-        if( Command cmd = parser.find( "-t", "--test" ) ) {
-            if( cmd.argsCount() == 0 )
-                cmd.raiseError( "Expected at least one argument" );
-            for( std::size_t i = 0; i < cmd.argsCount(); ++i )
-                config.testSpecs.push_back( cmd[i] );
-        }
+                    OutputTestCases( xml, *it );
+                }
 
-        if( Command cmd = parser.find( "-r", "--reporter" ) ) {
-            if( cmd.argsCount() != 1 )
-                cmd.raiseError( "Expected one argument" );
-            config.reporter = cmd[0];
+                xml.scopedElement( "system-out" ).writeText( trim( m_stdOut.str() ) );
+                xml.scopedElement( "system-err" ).writeText( trim( m_stdErr.str() ) );
+            }
         }
 
-        if( Command cmd = parser.find( "-o", "--out" ) ) {
-            if( cmd.argsCount() == 0 )
-                cmd.raiseError( "Expected filename" );
-            if( cmd[0][0] == '%' )
-                config.stream = cmd[0].substr( 1 );
-            else
-                config.outputFilename = cmd[0];
-        }
+        void OutputTestCases( XmlWriter& xml, const Stats& stats ) {
+            std::vector<TestCaseStats>::const_iterator it = stats.m_testCaseStats.begin();
+            std::vector<TestCaseStats>::const_iterator itEnd = stats.m_testCaseStats.end();
+            for(; it != itEnd; ++it ) {
+                xml.writeBlankLine();
+                xml.writeComment( "Test case" );
 
-        if( Command cmd = parser.find( "-s", "--success" ) ) {
-            if( cmd.argsCount() != 0 )
-                cmd.raiseError( "Does not accept arguments" );
-            config.includeWhichResults = Include::SuccessfulResults;
-        }
+                XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
+                xml.writeAttribute( "classname", it->m_className );
+                xml.writeAttribute( "name", it->m_name );
+                xml.writeAttribute( "time", "tbd" );
 
-        if( Command cmd = parser.find( "-b", "--break" ) ) {
-            if( cmd.argsCount() != 0 )
-                cmd.raiseError( "Does not accept arguments" );
-            config.shouldDebugBreak = true;
+                OutputTestResult( xml, *it );
+            }
         }
 
-        if( Command cmd = parser.find( "-n", "--name" ) ) {
-            if( cmd.argsCount() != 1 )
-                cmd.raiseError( "Expected a name" );
-            config.name = cmd[0];
-        }
+        void OutputTestResult( XmlWriter& xml, const TestCaseStats& stats ) {
+            std::vector<TestStats>::const_iterator it = stats.m_testStats.begin();
+            std::vector<TestStats>::const_iterator itEnd = stats.m_testStats.end();
+            for(; it != itEnd; ++it ) {
+                if( it->m_element != "success" ) {
+                    XmlWriter::ScopedElement e = xml.scopedElement( it->m_element );
 
-        if( Command cmd = parser.find( "-a", "--abort" ) ) {
-            if( cmd.argsCount() > 1 )
-                cmd.raiseError( "Only accepts 0-1 arguments" );
-            int threshold = 1;
-            if( cmd.argsCount() == 1 ) {
-                std::stringstream ss;
-                ss << cmd[0];
-                ss >> threshold;
-                if( ss.fail() || threshold <= 0 )
-                    cmd.raiseError( "threshold must be a number greater than zero" );
+                    xml.writeAttribute( "message", it->m_message );
+                    xml.writeAttribute( "type", it->m_resultType );
+                    if( !it->m_content.empty() )
+                        xml.writeText( it->m_content );
+                }
             }
-            config.cutoff = threshold;
         }
 
-        if( Command cmd = parser.find( "-nt", "--nothrow" ) ) {
-            if( cmd.argsCount() != 0 )
-                cmd.raiseError( "Does not accept arguments" );
-            config.allowThrows = false;
-        }
+    private:
+        ReporterConfig m_config;
+        bool m_currentTestSuccess;
 
-    }
+        Stats m_testSuiteStats;
+        Stats* m_currentStats;
+        std::vector<Stats> m_statsForSuites;
+        std::ostringstream m_stdOut;
+        std::ostringstream m_stdErr;
+    };
 
 } // end namespace Catch
 
-// #included from: internal/catch_list.hpp
-#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
+// #included from: internal/catch_commandline.hpp
+#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
 
-#include <limits>
+// #included from: catch_config.hpp
+#define TWOBLUECUBES_CATCH_RUNNERCONFIG_HPP_INCLUDED
 
-namespace Catch {
-    inline int List( Config& config ) {
+#include <memory>
+#include <vector>
+#include <string>
+#include <iostream>
 
-        if( config.listWhat() & List::Reports ) {
-            std::cout << "Available reports:\n";
-            IReporterRegistry::FactoryMap::const_iterator it = getRegistryHub().getReporterRegistry().getFactories().begin();
-            IReporterRegistry::FactoryMap::const_iterator itEnd = getRegistryHub().getReporterRegistry().getFactories().end();
-            for(; it != itEnd; ++it ) {
-                // !TBD: consider listAs()
-                std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n";
-            }
-            std::cout << std::endl;
-        }
+namespace Catch {
 
-        if( config.listWhat() & List::Tests ) {
-            std::cout << "Available tests:\n";
-            std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
-            std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
-            for(; it != itEnd; ++it ) {
-                // !TBD: consider listAs()
-                std::cout << "\t" << it->getName() << "\n\t\t '" << it->getDescription() << "'\n";
-            }
-            std::cout << std::endl;
-        }
+    struct Include { enum WhichResults {
+        FailedOnly,
+        SuccessfulResults
+    }; };
 
-        if( ( config.listWhat() & List::All ) == 0 ) {
-            std::cerr << "Unknown list type" << std::endl;
-            return (std::numeric_limits<int>::max)();
-        }
+    struct List{ enum What {
+        None = 0,
 
-        return 0;
-    }
+        Reports = 1,
+        Tests = 2,
+        All = 3,
 
-} // end namespace Catch
+        WhatMask = 0xf,
 
-// #included from: reporters/catch_reporter_basic.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED
+        AsText = 0x10,
+        AsXml = 0x11,
 
-// #included from: ../internal/catch_reporter_registrars.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
+        AsMask = 0xf0
+    }; };
 
-namespace Catch {
+    struct ConfigData {
+        ConfigData()
+        :   listSpec( List::None ),
+            shouldDebugBreak( false ),
+            includeWhichResults( Include::FailedOnly ),
+            cutoff( -1 ),
+            allowThrows( true )
+        {}
 
-    template<typename T>
-    class ReporterRegistrar {
+        std::string reporter;
+        std::string outputFilename;
+        List::What listSpec;
+        std::vector<std::string> testSpecs;
+        bool shouldDebugBreak;
+        std::string stream;
+        Include::WhichResults includeWhichResults;
+        std::string name;
+        int cutoff;
+        bool allowThrows;
+    };
 
-        class ReporterFactory : public IReporterFactory {
+    class Config : public IConfig {
+    private:
+        Config( const Config& other );
+        Config& operator = ( const Config& other );
+        virtual void dummy();
+    public:
 
-            virtual IReporter* create( const ReporterConfig& config ) const {
-                return new T( config );
-            }
+        Config()
+        :   m_streambuf( NULL ),
+            m_os( std::cout.rdbuf() )
+        {}
 
-            virtual std::string getDescription() const {
-                return T::getDescription();
-            }
-        };
+        Config( const ConfigData& data )
+        :   m_data( data ),
+            m_streambuf( NULL ),
+            m_os( std::cout.rdbuf() )
+        {}
 
-    public:
+        virtual ~Config() {
+            m_os.rdbuf( std::cout.rdbuf() );
+            delete m_streambuf;
+        }
 
-        ReporterRegistrar( const std::string& name ) {
-            getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
+        void setFilename( const std::string& filename ) {
+            m_data.outputFilename = filename;
         }
-    };
-}
 
-#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
-    Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
+        bool testsSpecified() const {
+            return !m_data.testSpecs.empty();
+        }
 
-// #included from: ../internal/catch_console_colour.hpp
-#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED
+        const std::vector<std::string>& getTestSpecs() const {
+            return m_data.testSpecs;
+        }
 
-namespace Catch {
+        List::What getListSpec( void ) const {
+            return m_data.listSpec;
+        }
 
-    struct ConsoleColourImpl;
+        const std::string& getFilename() const {
+            return m_data.outputFilename ;
+        }
 
-    class TextColour : NonCopyable {
-    public:
+        List::What listWhat() const {
+            return static_cast<List::What>( m_data.listSpec & List::WhatMask );
+        }
 
-        enum Colours {
-            None,
+        List::What listAs() const {
+            return static_cast<List::What>( m_data.listSpec & List::AsMask );
+        }
 
-            FileName,
-            ResultError,
-            ResultSuccess,
+        std::string getName() const {
+            return m_data.name;
+        }
 
-            Error,
-            Success,
+        bool shouldDebugBreak() const {
+            return m_data.shouldDebugBreak;
+        }
 
-            OriginalExpression,
-            ReconstructedExpression
-        };
+        virtual std::ostream& stream() const {
+            return m_os;
+        }
 
-        TextColour( Colours colour = None );
-        void set( Colours colour );
-        ~TextColour();
+        void setStreamBuf( std::streambuf* buf ) {
+            m_os.rdbuf( buf ? buf : std::cout.rdbuf() );
+        }
 
-    private:
-        ConsoleColourImpl* m_impl;
-    };
+        void useStream( const std::string& streamName ) {
+            std::streambuf* newBuf = createStreamBuf( streamName );
+            setStreamBuf( newBuf );
+            delete m_streambuf;
+            m_streambuf = newBuf;
+        }
 
-} // end namespace Catch
+        virtual bool includeSuccessfulResults() const {
+            return m_data.includeWhichResults == Include::SuccessfulResults;
+        }
 
-namespace Catch {
+        int getCutoff() const {
+            return m_data.cutoff;
+        }
 
-    struct pluralise {
-        pluralise( std::size_t count, const std::string& label )
-        :   m_count( count ),
-            m_label( label )
-        {}
+        virtual bool allowThrows() const {
+            return m_data.allowThrows;
+        }
 
-        friend std::ostream& operator << ( std::ostream& os, const pluralise& pluraliser ) {
-            os << pluraliser.m_count << " " << pluraliser.m_label;
-            if( pluraliser.m_count != 1 )
-                os << "s";
-            return os;
+        ConfigData& data() {
+            return m_data;
         }
 
-        std::size_t m_count;
-        std::string m_label;
+    private:
+        ConfigData m_data;
+
+        // !TBD Move these out of here
+        std::streambuf* m_streambuf;
+        mutable std::ostream m_os;
     };
 
-    class BasicReporter : public SharedImpl<IReporter> {
+} // end namespace Catch
 
-        struct SpanInfo {
+namespace Catch {
 
-            SpanInfo()
-            :   emitted( false )
-            {}
+    class Command {
+    public:
+        Command(){}
 
-            SpanInfo( const std::string& spanName )
-            :   name( spanName ),
-                emitted( false )
-            {}
+        explicit Command( const std::string& name ) : m_name( name ) {}
 
-            SpanInfo( const SpanInfo& other )
-            :   name( other.name ),
-                emitted( other.emitted )
-            {}
+        Command& operator += ( const std::string& arg ) {
+            m_args.push_back( arg );
+            return *this;
+        }
+        Command& operator += ( const Command& other ) {
+            std::copy( other.m_args.begin(), other.m_args.end(), std::back_inserter( m_args ) );
+            if( m_name.empty() )
+                m_name = other.m_name;
+            return *this;
+        }
+        Command operator + ( const Command& other ) {
+            Command newCommand( *this );
+            newCommand += other;
+            return newCommand;
+        }
 
-            std::string name;
-            bool emitted;
-        };
+        operator SafeBool::type() const {
+            return SafeBool::makeSafe( !m_name.empty() );
+        }
 
-    public:
-        BasicReporter( const ReporterConfig& config )
-        :   m_config( config ),
-            m_firstSectionInTestCase( true ),
-            m_aborted( false )
-        {}
+        std::string name() const { return m_name; }
+        std::string operator[]( std::size_t i ) const { return m_args[i]; }
+        std::size_t argsCount() const { return m_args.size(); }
 
-        static std::string getDescription() {
-            return "Reports test results as lines of text";
+        CATCH_ATTRIBUTE_NORETURN
+        void raiseError( const std::string& message ) const {
+            std::ostringstream oss;
+            oss << "Error while parsing " << m_name << ". " << message << ".";
+            if( m_args.size() > 0 )
+                oss << " Arguments where:";
+            for( std::size_t i = 0; i < m_args.size(); ++i )
+                oss << " " << m_args[i];
+            throw std::domain_error( oss.str() );
         }
 
     private:
 
-        void ReportCounts( const std::string& label, const Counts& counts, const std::string& allPrefix = "All " ) {
-            if( counts.passed )
-                m_config.stream << counts.failed << " of " << counts.total() << " " << label << "s failed";
-            else
-                m_config.stream << ( counts.failed > 1 ? allPrefix : "" ) << pluralise( counts.failed, label ) << " failed";
-        }
-
-        void ReportCounts( const Totals& totals, const std::string& allPrefix = "All " ) {
-            if( totals.assertions.total() == 0 ) {
-                m_config.stream << "No tests ran";
-            }
-            else if( totals.assertions.failed ) {
-                TextColour colour( TextColour::ResultError );
-                ReportCounts( "test case", totals.testCases, allPrefix );
-                if( totals.testCases.failed > 0 ) {
-                    m_config.stream << " (";
-                    ReportCounts( "assertion", totals.assertions, allPrefix );
-                    m_config.stream << ")";
-                }
-            }
-            else {
-                TextColour colour( TextColour::ResultSuccess );
-                m_config.stream   << allPrefix << "tests passed ("
-                                    << pluralise( totals.assertions.passed, "assertion" ) << " in "
-                                    << pluralise( totals.testCases.passed, "test case" ) << ")";
-            }
-        }
+        std::string m_name;
+        std::vector<std::string> m_args;
+    };
 
-    private: // IReporter
+    class CommandParser {
+    public:
+        CommandParser( int argc, char const * const * argv ) : m_argc( static_cast<std::size_t>( argc ) ), m_argv( argv ) {}
 
-        virtual bool shouldRedirectStdout() const {
-            return false;
+        Command find( const std::string& arg1,  const std::string& arg2, const std::string& arg3 ) const {
+            return find( arg1 ) + find( arg2 ) + find( arg3 );
         }
 
-        virtual void StartTesting() {
-            m_testingSpan = SpanInfo();
+        Command find( const std::string& shortArg, const std::string& longArg ) const {
+            return find( shortArg ) + find( longArg );
         }
-
-        virtual void Aborted() {
-            m_aborted = true;
+        Command find( const std::string& arg ) const {
+            for( std::size_t i = 0; i < m_argc; ++i  )
+                if( m_argv[i] == arg )
+                    return getArgs( i );
+            return Command();
         }
 
-        virtual void EndTesting( const Totals& totals ) {
-            // Output the overall test results even if "Started Testing" was not emitted
-            if( m_aborted ) {
-                m_config.stream << "\n[Testing aborted. ";
-                ReportCounts( totals, "The first " );
-            }
-            else {
-                m_config.stream << "\n[Testing completed. ";
-                ReportCounts( totals );
-            }
-            m_config.stream << "]\n" << std::endl;
+    private:
+        Command getArgs( std::size_t from ) const {
+            Command command( m_argv[from] );
+            for( std::size_t i = from+1; i < m_argc && m_argv[i][0] != '-'; ++i  )
+                command += m_argv[i];
+            return command;
         }
 
-        virtual void StartGroup( const std::string& groupName ) {
-            m_groupSpan = groupName;
-        }
+        std::size_t m_argc;
+        char const * const * m_argv;
+    };
 
-        virtual void EndGroup( const std::string& groupName, const Totals& totals ) {
-            if( m_groupSpan.emitted && !groupName.empty() ) {
-                m_config.stream << "[End of group: '" << groupName << "'. ";
-                ReportCounts( totals );
-                m_config.stream << "]\n" << std::endl;
-                m_groupSpan = SpanInfo();
+    inline void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
+
+        if( Command cmd = parser.find( "-l", "--list" ) ) {
+            if( cmd.argsCount() > 2 )
+                cmd.raiseError( "Expected upto 2 arguments" );
+
+            List::What listSpec = List::All;
+            if( cmd.argsCount() >= 1 ) {
+                if( cmd[0] == "tests" )
+                    config.listSpec = List::Tests;
+                else if( cmd[0] == "reporters" )
+                    config.listSpec = List::Reports;
+                else
+                    cmd.raiseError( "Expected [tests] or [reporters]" );
+            }
+            if( cmd.argsCount() >= 2 ) {
+                if( cmd[1] == "xml" )
+                    config.listSpec = static_cast<List::What>( listSpec | List::AsXml );
+                else if( cmd[1] == "text" )
+                    config.listSpec = static_cast<List::What>( listSpec | List::AsText );
+                else
+                    cmd.raiseError( "Expected [xml] or [text]" );
             }
         }
 
-        virtual void StartTestCase( const TestCaseInfo& testInfo ) {
-            m_testSpan = testInfo.getName();
+        if( Command cmd = parser.find( "-t", "--test" ) ) {
+            if( cmd.argsCount() == 0 )
+                cmd.raiseError( "Expected at least one argument" );
+            for( std::size_t i = 0; i < cmd.argsCount(); ++i )
+                config.testSpecs.push_back( cmd[i] );
         }
 
-        virtual void StartSection( const std::string& sectionName, const std::string& ) {
-            m_sectionSpans.push_back( SpanInfo( sectionName ) );
+        if( Command cmd = parser.find( "-r", "--reporter" ) ) {
+            if( cmd.argsCount() != 1 )
+                cmd.raiseError( "Expected one argument" );
+            config.reporter = cmd[0];
         }
 
-        virtual void EndSection( const std::string& sectionName, const Counts& assertions ) {
-            SpanInfo& sectionSpan = m_sectionSpans.back();
-            if( sectionSpan.emitted && !sectionSpan.name.empty() ) {
-                m_config.stream << "[End of section: '" << sectionName << "' ";
-
-                if( assertions.failed ) {
-                    TextColour colour( TextColour::ResultError );
-                    ReportCounts( "assertion", assertions);
-                }
-                else {
-                    TextColour colour( TextColour::ResultSuccess );
-                    m_config.stream   << ( assertions.passed > 1 ? "All " : "" )
-                                        << pluralise( assertions.passed, "assertion" ) << " passed" ;
-                }
-                m_config.stream << "]\n" << std::endl;
-            }
-            m_sectionSpans.pop_back();
+        if( Command cmd = parser.find( "-o", "--out" ) ) {
+            if( cmd.argsCount() == 0 )
+                cmd.raiseError( "Expected filename" );
+            if( cmd[0][0] == '%' )
+                config.stream = cmd[0].substr( 1 );
+            else
+                config.outputFilename = cmd[0];
         }
 
-        virtual void Result( const ResultInfo& resultInfo ) {
-            if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
-                return;
-
-            StartSpansLazily();
-
-            if( !resultInfo.getFilename().empty() ) {
-                TextColour colour( TextColour::FileName );
-                m_config.stream << SourceLineInfo( resultInfo.getFilename(), resultInfo.getLine() );
-            }
-
-            if( resultInfo.hasExpression() ) {
-                TextColour colour( TextColour::OriginalExpression );
-                m_config.stream << resultInfo.getExpression();
-                if( resultInfo.ok() ) {
-                    TextColour successColour( TextColour::Success );
-                    m_config.stream << " succeeded";
-                }
-                else {
-                    TextColour errorColour( TextColour::Error );
-                    m_config.stream << " failed";
-                }
-            }
-            switch( resultInfo.getResultType() ) {
-                case ResultWas::ThrewException:
-                {
-                    TextColour colour( TextColour::Error );
-                    if( resultInfo.hasExpression() )
-                        m_config.stream << " with unexpected";
-                    else
-                        m_config.stream << "Unexpected";
-                    m_config.stream << " exception with message: '" << resultInfo.getMessage() << "'";
-                }
-                    break;
-                case ResultWas::DidntThrowException:
-                {
-                    TextColour colour( TextColour::Error );
-                    if( resultInfo.hasExpression() )
-                        m_config.stream << " because no exception was thrown where one was expected";
-                    else
-                        m_config.stream << "No exception thrown where one was expected";
-                }
-                    break;
-                case ResultWas::Info:
-                    streamVariableLengthText( "info", resultInfo.getMessage() );
-                    break;
-                case ResultWas::Warning:
-                    m_config.stream << "warning:\n'" << resultInfo.getMessage() << "'";
-                    break;
-                case ResultWas::ExplicitFailure:
-                {
-                    TextColour colour( TextColour::Error );
-                    m_config.stream << "failed with message: '" << resultInfo.getMessage() << "'";
-                }
-                    break;
-                case ResultWas::Unknown: // These cases are here to prevent compiler warnings
-                case ResultWas::Ok:
-                case ResultWas::FailureBit:
-                case ResultWas::ExpressionFailed:
-                case ResultWas::Exception:
-                default:
-                    if( !resultInfo.hasExpression() ) {
-                        if( resultInfo.ok() ) {
-                            TextColour colour( TextColour::Success );
-                            m_config.stream << " succeeded";
-                        }
-                        else {
-                            TextColour colour( TextColour::Error );
-                            m_config.stream << " failed";
-                        }
-                    }
-                    break;
-            }
+        if( Command cmd = parser.find( "-s", "--success" ) ) {
+            if( cmd.argsCount() != 0 )
+                cmd.raiseError( "Does not accept arguments" );
+            config.includeWhichResults = Include::SuccessfulResults;
+        }
 
-            if( resultInfo.hasExpandedExpression() ) {
-                m_config.stream << " for: ";
-                TextColour colour( TextColour::ReconstructedExpression );
-                m_config.stream << resultInfo.getExpandedExpression();
-            }
-            m_config.stream << std::endl;
+        if( Command cmd = parser.find( "-b", "--break" ) ) {
+            if( cmd.argsCount() != 0 )
+                cmd.raiseError( "Does not accept arguments" );
+            config.shouldDebugBreak = true;
         }
 
-        virtual void EndTestCase(   const TestCaseInfo& testInfo,
-                                    const Totals& totals,
-                                    const std::string& stdOut,
-                                    const std::string& stdErr ) {
-            if( !stdOut.empty() ) {
-                StartSpansLazily();
-                streamVariableLengthText( "stdout", stdOut );
-            }
+        if( Command cmd = parser.find( "-n", "--name" ) ) {
+            if( cmd.argsCount() != 1 )
+                cmd.raiseError( "Expected a name" );
+            config.name = cmd[0];
+        }
 
-            if( !stdErr.empty() ) {
-                StartSpansLazily();
-                streamVariableLengthText( "stderr", stdErr );
+        if( Command cmd = parser.find( "-a", "--abort" ) ) {
+            if( cmd.argsCount() > 1 )
+                cmd.raiseError( "Only accepts 0-1 arguments" );
+            int threshold = 1;
+            if( cmd.argsCount() == 1 ) {
+                std::stringstream ss;
+                ss << cmd[0];
+                ss >> threshold;
+                if( ss.fail() || threshold <= 0 )
+                    cmd.raiseError( "threshold must be a number greater than zero" );
             }
+            config.cutoff = threshold;
+        }
 
-            if( m_testSpan.emitted ) {
-                m_config.stream << "[Finished: '" << testInfo.getName() << "' ";
-                ReportCounts( totals );
-                m_config.stream << "]" << std::endl;
-            }
+        if( Command cmd = parser.find( "-nt", "--nothrow" ) ) {
+            if( cmd.argsCount() != 0 )
+                cmd.raiseError( "Does not accept arguments" );
+            config.allowThrows = false;
         }
 
-    private: // helpers
+    }
 
-        void StartSpansLazily() {
-            if( !m_testingSpan.emitted ) {
-                if( m_config.name.empty() )
-                    m_config.stream << "[Started testing]" << std::endl;
-                else
-                    m_config.stream << "[Started testing: " << m_config.name << "]" << std::endl;
-                m_testingSpan.emitted = true;
-            }
+} // end namespace Catch
 
-            if( !m_groupSpan.emitted && !m_groupSpan.name.empty() ) {
-                m_config.stream << "[Started group: '" << m_groupSpan.name << "']" << std::endl;
-                m_groupSpan.emitted = true;
-            }
+// #included from: internal/catch_list.hpp
+#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
 
-            if( !m_testSpan.emitted ) {
-                m_config.stream << std::endl << "[Running: " << m_testSpan.name << "]" << std::endl;
-                m_testSpan.emitted = true;
-            }
+#include <limits>
 
-            if( !m_sectionSpans.empty() ) {
-                SpanInfo& sectionSpan = m_sectionSpans.back();
-                if( !sectionSpan.emitted && !sectionSpan.name.empty() ) {
-                    if( m_firstSectionInTestCase ) {
-                        m_config.stream << "\n";
-                        m_firstSectionInTestCase = false;
-                    }
-                    std::vector<SpanInfo>::iterator it = m_sectionSpans.begin();
-                    std::vector<SpanInfo>::iterator itEnd = m_sectionSpans.end();
-                    for(; it != itEnd; ++it ) {
-                        SpanInfo& prevSpan = *it;
-                        if( !prevSpan.emitted && !prevSpan.name.empty() ) {
-                            m_config.stream << "[Started section: '" << prevSpan.name << "']" << std::endl;
-                            prevSpan.emitted = true;
-                        }
-                    }
-                }
+namespace Catch {
+    inline int List( Config& config ) {
+
+        if( config.listWhat() & List::Reports ) {
+            std::cout << "Available reports:\n";
+            IReporterRegistry::FactoryMap::const_iterator it = getRegistryHub().getReporterRegistry().getFactories().begin();
+            IReporterRegistry::FactoryMap::const_iterator itEnd = getRegistryHub().getReporterRegistry().getFactories().end();
+            for(; it != itEnd; ++it ) {
+                // !TBD: consider listAs()
+                std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n";
             }
+            std::cout << std::endl;
         }
 
-        void streamVariableLengthText( const std::string& prefix, const std::string& text ) {
-            std::string trimmed = trim( text );
-            if( trimmed.find_first_of( "\r\n" ) == std::string::npos ) {
-                m_config.stream << "[" << prefix << ": " << trimmed << "]\n";
-            }
-            else {
-                m_config.stream << "\n[" << prefix << "] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << trimmed
-                << "\n[end of " << prefix << "] <<<<<<<<<<<<<<<<<<<<<<<<\n";
+        if( config.listWhat() & List::Tests ) {
+            std::cout << "Available tests:\n";
+            std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
+            std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
+            for(; it != itEnd; ++it ) {
+                // !TBD: consider listAs()
+                std::cout << "\t" << it->getName() << "\n\t\t '" << it->getDescription() << "'\n";
             }
+            std::cout << std::endl;
         }
 
-    private:
-        ReporterConfig m_config;
-        bool m_firstSectionInTestCase;
+        if( ( config.listWhat() & List::All ) == 0 ) {
+            std::cerr << "Unknown list type" << std::endl;
+            return (std::numeric_limits<int>::max)();
+        }
 
-        SpanInfo m_testingSpan;
-        SpanInfo m_groupSpan;
-        SpanInfo m_testSpan;
-        std::vector<SpanInfo> m_sectionSpans;
-        bool m_aborted;
-    };
+        return 0;
+    }
 
 } // end namespace Catch
 
-// #included from: reporters/catch_reporter_xml.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
+// #included from: internal/catch_runner_impl.hpp
+#define TWOBLUECUBES_INTERNAL_CATCH_RUNNER_HPP_INCLUDED
 
-// #included from: ../internal/catch_xmlwriter.hpp
-#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
+// #included from: catch_running_test.hpp
+#define TWOBLUECUBES_INTERNAL_CATCH_RUNNING_TEST_HPP_INCLUDED
+
+// #included from: catch_section_info.hpp
+#define TWOBLUECUBES_INTERNAL_CATCH_SECTION_INFO_HPP_INCLUDED
 
-#include <sstream>
+#include <map>
 #include <string>
-#include <vector>
 
 namespace Catch {
 
-    class XmlWriter {
+    class SectionInfo {
     public:
 
-        class ScopedElement {
-        public:
-            ScopedElement( XmlWriter* writer )
-            :   m_writer( writer )
-            {}
-
-            ScopedElement( const ScopedElement& other )
-            :   m_writer( other.m_writer ){
-                other.m_writer = NULL;
-            }
-
-            ~ScopedElement() {
-                if( m_writer )
-                    m_writer->endElement();
-            }
-
-            ScopedElement& writeText( const std::string& text ) {
-                m_writer->writeText( text );
-                return *this;
-            }
-
-            template<typename T>
-            ScopedElement& writeAttribute( const std::string& name, const T& attribute ) {
-                m_writer->writeAttribute( name, attribute );
-                return *this;
-            }
-
-        private:
-            mutable XmlWriter* m_writer;
+        enum Status {
+            Root,
+            Unknown,
+            Branch,
+            TestedBranch,
+            TestedLeaf
         };
 
-        XmlWriter()
-        :   m_tagIsOpen( false ),
-            m_needsNewline( false ),
-            m_os( &std::cout )
+        SectionInfo( SectionInfo* parent )
+        :   m_status( Unknown ),
+            m_parent( parent )
         {}
 
-        XmlWriter( std::ostream& os )
-        :   m_tagIsOpen( false ),
-            m_needsNewline( false ),
-            m_os( &os )
+        SectionInfo()
+        :   m_status( Root ),
+            m_parent( NULL )
         {}
 
-        ~XmlWriter() {
-            while( !m_tags.empty() )
-                endElement();
-        }
-
-        XmlWriter& operator = ( const XmlWriter& other ) {
-            XmlWriter temp( other );
-            swap( temp );
-            return *this;
+        ~SectionInfo() {
+            deleteAllValues( m_subSections );
         }
 
-        void swap( XmlWriter& other ) {
-            std::swap( m_tagIsOpen, other.m_tagIsOpen );
-            std::swap( m_needsNewline, other.m_needsNewline );
-            std::swap( m_tags, other.m_tags );
-            std::swap( m_indent, other.m_indent );
-            std::swap( m_os, other.m_os );
+        bool shouldRun() const {
+            return m_status < TestedBranch;
         }
 
-        XmlWriter& startElement( const std::string& name ) {
-            ensureTagClosed();
-            newlineIfNecessary();
-            stream() << m_indent << "<" << name;
-            m_tags.push_back( name );
-            m_indent += "  ";
-            m_tagIsOpen = true;
-            return *this;
+        bool ran() {
+            if( m_status < Branch ) {
+                m_status = TestedLeaf;
+                return true;
+            }
+            return false;
         }
 
-        ScopedElement scopedElement( const std::string& name ) {
-            ScopedElement scoped( this );
-            startElement( name );
-            return scoped;
+        void ranToCompletion() {
+            if( m_status == Branch && !hasUntestedSections() )
+                m_status = TestedBranch;
         }
 
-        XmlWriter& endElement() {
-            newlineIfNecessary();
-            m_indent = m_indent.substr( 0, m_indent.size()-2 );
-            if( m_tagIsOpen ) {
-                stream() << "/>\n";
-                m_tagIsOpen = false;
-            }
-            else {
-                stream() << m_indent << "</" << m_tags.back() << ">\n";
-            }
-            m_tags.pop_back();
-            return *this;
+        SectionInfo* findSubSection( const std::string& name ) {
+            std::map<std::string, SectionInfo*>::const_iterator it = m_subSections.find( name );
+            return it != m_subSections.end()
+                        ? it->second
+                        : NULL;
         }
 
-        XmlWriter& writeAttribute( const std::string& name, const std::string& attribute ) {
-            if( !name.empty() && !attribute.empty() ) {
-                stream() << " " << name << "=\"";
-                writeEncodedText( attribute );
-                stream() << "\"";
-            }
-            return *this;
+        SectionInfo* addSubSection( const std::string& name ) {
+            SectionInfo* subSection = new SectionInfo( this );
+            m_subSections.insert( std::make_pair( name, subSection ) );
+            m_status = Branch;
+            return subSection;
         }
 
-        XmlWriter& writeAttribute( const std::string& name, bool attribute ) {
-            stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
-            return *this;
+        SectionInfo* getParent() {
+            return m_parent;
         }
 
-        template<typename T>
-        XmlWriter& writeAttribute( const std::string& name, const T& attribute ) {
-            if( !name.empty() )
-                stream() << " " << name << "=\"" << attribute << "\"";
-            return *this;
-        }
+        bool hasUntestedSections() const {
+            if( m_status == Unknown )
+                return true;
 
-        XmlWriter& writeText( const std::string& text ) {
-            if( !text.empty() ){
-                bool tagWasOpen = m_tagIsOpen;
-                ensureTagClosed();
-                if( tagWasOpen )
-                    stream() << m_indent;
-                writeEncodedText( text );
-                m_needsNewline = true;
+            std::map<std::string, SectionInfo*>::const_iterator it = m_subSections.begin();
+            std::map<std::string, SectionInfo*>::const_iterator itEnd = m_subSections.end();
+            for(; it != itEnd; ++it ) {
+                if( it->second->hasUntestedSections() )
+                    return true;
             }
-            return *this;
+            return false;
         }
 
-        XmlWriter& writeComment( const std::string& text ) {
-            ensureTagClosed();
-            stream() << m_indent << "<!--" << text << "-->";
-            m_needsNewline = true;
-            return *this;
-        }
+    private:
+        Status m_status;
+        std::map<std::string, SectionInfo*> m_subSections;
+        SectionInfo* m_parent;
+    };
+}
 
-        XmlWriter& writeBlankLine() {
-            ensureTagClosed();
-            stream() << "\n";
-            return *this;
-        }
+namespace Catch {
 
-    private:
+    class RunningTest {
 
-        std::ostream& stream() {
-            return *m_os;
-        }
+        enum RunStatus {
+            NothingRun,
+            EncounteredASection,
+            RanAtLeastOneSection,
+            RanToCompletionWithSections,
+            RanToCompletionWithNoSections
+        };
 
-        void ensureTagClosed() {
-            if( m_tagIsOpen ) {
-                stream() << ">\n";
-                m_tagIsOpen = false;
-            }
-        }
+    public:
+        explicit RunningTest( const TestCaseInfo* info = NULL )
+        :   m_info( info ),
+            m_runStatus( RanAtLeastOneSection ),
+            m_currentSection( &m_rootSection ),
+            m_changed( false )
+        {}
 
-        void newlineIfNecessary() {
-            if( m_needsNewline ) {
-                stream() << "\n";
-                m_needsNewline = false;
-            }
+        bool wasSectionSeen() const {
+            return  m_runStatus == RanAtLeastOneSection ||
+                    m_runStatus == RanToCompletionWithSections;
         }
 
-        void writeEncodedText( const std::string& text ) {
-            static const char* charsToEncode = "<&\"";
-            std::string mtext = text;
-            std::string::size_type pos = mtext.find_first_of( charsToEncode );
-            while( pos != std::string::npos ) {
-                stream() << mtext.substr( 0, pos );
+        void reset() {
+            m_runStatus = NothingRun;
+            m_changed = false;
+            m_lastSectionToRun = NULL;
+        }
 
-                switch( mtext[pos] ) {
-                    case '<':
-                        stream() << "&lt;";
-                        break;
-                    case '&':
-                        stream() << "&amp;";
-                        break;
-                    case '\"':
-                        stream() << "&quot;";
-                        break;
+        void ranToCompletion() {
+            if( m_runStatus == RanAtLeastOneSection ||
+                m_runStatus == EncounteredASection ) {
+                m_runStatus = RanToCompletionWithSections;
+                if( m_lastSectionToRun ) {
+                    m_lastSectionToRun->ranToCompletion();
+                    m_changed = true;
                 }
-                mtext = mtext.substr( pos+1 );
-                pos = mtext.find_first_of( charsToEncode );
             }
-            stream() << mtext;
+            else {
+                m_runStatus = RanToCompletionWithNoSections;
+            }
         }
 
-        bool m_tagIsOpen;
-        bool m_needsNewline;
-        std::vector<std::string> m_tags;
-        std::string m_indent;
-        std::ostream* m_os;
-    };
+        bool addSection( const std::string& name ) {
+            if( m_runStatus == NothingRun )
+                m_runStatus = EncounteredASection;
 
-}
-namespace Catch {
-    class XmlReporter : public SharedImpl<IReporter> {
-    public:
-        XmlReporter( const ReporterConfig& config ) : m_config( config ) {}
+            SectionInfo* thisSection = m_currentSection->findSubSection( name );
+            if( !thisSection ) {
+                thisSection = m_currentSection->addSubSection( name );
+                m_changed = true;
+            }
 
-        static std::string getDescription() {
-            return "Reports test results as an XML document";
+            if( !wasSectionSeen() && thisSection->shouldRun() ) {
+                m_currentSection = thisSection;
+                m_lastSectionToRun = NULL;
+                return true;
+            }
+            return false;
         }
 
-    private: // IReporter
-
-        virtual bool shouldRedirectStdout() const {
-            return true;
+        void endSection( const std::string& ) {
+            if( m_currentSection->ran() ) {
+                m_runStatus = RanAtLeastOneSection;
+                m_changed = true;
+            }
+            else if( m_runStatus == EncounteredASection ) {
+                m_runStatus = RanAtLeastOneSection;
+                m_lastSectionToRun = m_currentSection;
+            }
+            m_currentSection = m_currentSection->getParent();
         }
 
-        virtual void StartTesting() {
-            m_xml = XmlWriter( m_config.stream );
-            m_xml.startElement( "Catch" );
-            if( !m_config.name.empty() )
-                m_xml.writeAttribute( "name", m_config.name );
+        const TestCaseInfo& getTestCaseInfo() const {
+            return *m_info;
         }
 
-        virtual void EndTesting( const Totals& totals ) {
-            m_xml.scopedElement( "OverallResults" )
-                .writeAttribute( "successes", totals.assertions.passed )
-                .writeAttribute( "failures", totals.assertions.failed );
-            m_xml.endElement();
+        bool hasUntestedSections() const {
+            return  m_runStatus == RanAtLeastOneSection ||
+                    ( m_rootSection.hasUntestedSections() && m_changed );
         }
 
-        virtual void StartGroup( const std::string& groupName ) {
-            m_xml.startElement( "Group" )
-                .writeAttribute( "name", groupName );
-        }
+    private:
+        const TestCaseInfo* m_info;
+        RunStatus m_runStatus;
+        SectionInfo m_rootSection;
+        SectionInfo* m_currentSection;
+        SectionInfo* m_lastSectionToRun;
+        bool m_changed;
+    };
+}
 
-        virtual void EndGroup( const std::string&, const Totals& totals ) {
-            m_xml.scopedElement( "OverallResults" )
-                .writeAttribute( "successes", totals.assertions.passed )
-                .writeAttribute( "failures", totals.assertions.failed );
-            m_xml.endElement();
-        }
+#include <set>
+#include <string>
 
-        virtual void StartSection( const std::string& sectionName, const std::string& description ) {
-            m_xml.startElement( "Section" )
-                .writeAttribute( "name", sectionName )
-                .writeAttribute( "description", description );
-        }
+namespace Catch {
 
-        virtual void EndSection( const std::string& /*sectionName*/, const Counts& assertions ) {
-            m_xml.scopedElement( "OverallResults" )
-                .writeAttribute( "successes", assertions.passed )
-                .writeAttribute( "failures", assertions.failed );
-            m_xml.endElement();
+    class StreamRedirect {
+
+    public:
+        StreamRedirect( std::ostream& stream, std::string& targetString )
+        :   m_stream( stream ),
+            m_prevBuf( stream.rdbuf() ),
+            m_targetString( targetString )
+        {
+            stream.rdbuf( m_oss.rdbuf() );
         }
 
-        virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
-            m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.getName() );
-            m_currentTestSuccess = true;
+        ~StreamRedirect() {
+            m_targetString += m_oss.str();
+            m_stream.rdbuf( m_prevBuf );
         }
 
-        virtual void Result( const Catch::ResultInfo& resultInfo ) {
-            if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
-                return;
+    private:
+        std::ostream& m_stream;
+        std::streambuf* m_prevBuf;
+        std::ostringstream m_oss;
+        std::string& m_targetString;
+    };
 
-            if( resultInfo.hasExpression() ) {
-                m_xml.startElement( "Expression" )
-                    .writeAttribute( "success", resultInfo.ok() )
-                    .writeAttribute( "filename", resultInfo.getFilename() )
-                    .writeAttribute( "line", resultInfo.getLine() );
+    ///////////////////////////////////////////////////////////////////////////
 
-                m_xml.scopedElement( "Original" )
-                    .writeText( resultInfo.getExpression() );
-                m_xml.scopedElement( "Expanded" )
-                    .writeText( resultInfo.getExpandedExpression() );
-                m_currentTestSuccess &= resultInfo.ok();
-            }
+    class Runner : public IResultCapture, public IRunner {
 
-            switch( resultInfo.getResultType() ) {
-                case ResultWas::ThrewException:
-                    m_xml.scopedElement( "Exception" )
-                        .writeAttribute( "filename", resultInfo.getFilename() )
-                        .writeAttribute( "line", resultInfo.getLine() )
-                        .writeText( resultInfo.getMessage() );
-                    m_currentTestSuccess = false;
-                    break;
-                case ResultWas::Info:
-                    m_xml.scopedElement( "Info" )
-                        .writeText( resultInfo.getMessage() );
-                    break;
-                case ResultWas::Warning:
-                    m_xml.scopedElement( "Warning" )
-                        .writeText( resultInfo.getMessage() );
-                    break;
-                case ResultWas::ExplicitFailure:
-                    m_xml.scopedElement( "Failure" )
-                        .writeText( resultInfo.getMessage() );
-                    m_currentTestSuccess = false;
-                    break;
-                case ResultWas::Unknown:
-                case ResultWas::Ok:
-                case ResultWas::FailureBit:
-                case ResultWas::ExpressionFailed:
-                case ResultWas::Exception:
-                case ResultWas::DidntThrowException:
-                default:
-                    break;
-            }
-            if( resultInfo.hasExpression() )
-                m_xml.endElement();
-        }
+        Runner( const Runner& );
+        void operator =( const Runner& );
 
-        virtual void Aborted() {
-            // !TBD
-        }
+    public:
 
-        virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string&, const std::string& ) {
-            m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess );
-            m_xml.endElement();
+        explicit Runner( Config& config, const Ptr<IReporter>& reporter )
+        :   m_context( getCurrentMutableContext() ),
+            m_runningTest( NULL ),
+            m_config( config ),
+            m_reporter( reporter ),
+            m_prevRunner( &m_context.getRunner() ),
+            m_prevResultCapture( &m_context.getResultCapture() ),
+            m_prevConfig( m_context.getConfig() )
+        {
+            m_context.setRunner( this );
+            m_context.setConfig( &m_config );
+            m_context.setResultCapture( this );
+            m_reporter->StartTesting();
         }
 
-    private:
-        ReporterConfig m_config;
-        bool m_currentTestSuccess;
-        XmlWriter m_xml;
-    };
+        virtual ~Runner() {
+            m_reporter->EndTesting( m_totals );
+            m_context.setRunner( m_prevRunner );
+            m_context.setConfig( NULL );
+            m_context.setResultCapture( m_prevResultCapture );
+            m_context.setConfig( m_prevConfig );
+        }
 
-} // end namespace Catch
+        virtual void runAll( bool runHiddenTests = false ) {
+            m_reporter->StartGroup( "" );
+            const std::vector<TestCaseInfo>& allTests = getRegistryHub().getTestCaseRegistry().getAllTests();
+            for( std::size_t i=0; i < allTests.size(); ++i ) {
+                if( runHiddenTests || !allTests[i].isHidden() ) {
+                    if( aborting() ) {
+                        m_reporter->Aborted();
+                        break;
+                    }
+                    runTest( allTests[i] );
+                }
+            }
+            m_reporter->EndGroup( "", getTotals() );
+        }
 
-// #included from: reporters/catch_reporter_junit.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
+        virtual std::size_t runMatching( const std::string& rawTestSpec ) {
 
-namespace Catch {
+            Totals prevTotals = getTotals();
+            m_reporter->StartGroup( rawTestSpec );
 
-    class JunitReporter : public SharedImpl<IReporter> {
+            TestSpec testSpec( rawTestSpec );
 
-        struct TestStats {
-            std::string m_element;
-            std::string m_resultType;
-            std::string m_message;
-            std::string m_content;
-        };
+            const std::vector<TestCaseInfo>& allTests = getRegistryHub().getTestCaseRegistry().getAllTests();
+            std::size_t testsRun = 0;
+            for( std::size_t i=0; i < allTests.size(); ++i ) {
+                if( testSpec.matches( allTests[i].getName() ) ) {
+                    if( aborting() ) {
+                        m_reporter->Aborted();
+                        break;
+                    }
+                    runTest( allTests[i] );
+                    testsRun++;
+                }
+            }
+            m_reporter->EndGroup( rawTestSpec, getTotals() - prevTotals );
+            return testsRun;
+        }
 
-        struct TestCaseStats {
+        void runTest( const TestCaseInfo& testInfo ) {
+            Totals prevTotals = m_totals;
 
-            TestCaseStats( const std::string& name = std::string() ) :m_name( name ){}
+            std::string redirectedCout;
+            std::string redirectedCerr;
 
-            double      m_timeInSeconds;
-            std::string m_status;
-            std::string m_className;
-            std::string m_name;
-            std::vector<TestStats> m_testStats;
-        };
+            m_reporter->StartTestCase( testInfo );
 
-        struct Stats {
+            m_runningTest = new RunningTest( &testInfo );
 
-            Stats( const std::string& name = std::string() )
-            :   m_testsCount( 0 ),
-                m_failuresCount( 0 ),
-                m_disabledCount( 0 ),
-                m_errorsCount( 0 ),
-                m_timeInSeconds( 0 ),
-                m_name( name )
-            {}
+            do {
+                do {
+//                    m_reporter->StartGroup( "test case run" );
+                    m_currentResult.setLineInfo( m_runningTest->getTestCaseInfo().getLineInfo() );
+                    runCurrentTest( redirectedCout, redirectedCerr );
+//                    m_reporter->EndGroup( "test case run", m_totals.delta( prevTotals ) );
+                }
+                while( m_runningTest->hasUntestedSections() && !aborting() );
+            }
+            while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
 
-            std::size_t m_testsCount;
-            std::size_t m_failuresCount;
-            std::size_t m_disabledCount;
-            std::size_t m_errorsCount;
-            double      m_timeInSeconds;
-            std::string m_name;
+            delete m_runningTest;
+            m_runningTest = NULL;
 
-            std::vector<TestCaseStats> m_testCaseStats;
-        };
+            Totals deltaTotals = m_totals.delta( prevTotals );
+            m_totals.testCases += deltaTotals.testCases;
+            m_reporter->EndTestCase( testInfo, deltaTotals, redirectedCout, redirectedCerr );
+        }
 
-    public:
-        JunitReporter( const ReporterConfig& config )
-        :   m_config( config ),
-            m_testSuiteStats( "AllTests" ),
-            m_currentStats( &m_testSuiteStats )
-        {}
+        virtual Totals getTotals() const {
+            return m_totals;
+        }
 
-        static std::string getDescription() {
-            return "Reports test results in an XML format that looks like Ant's junitreport target";
+        const Config& config() const {
+            return m_config;
         }
 
-    private: // IReporter
+    private: // IResultCapture
 
-        virtual bool shouldRedirectStdout() const {
-            return true;
+        virtual ResultAction::Value acceptResult( bool result ) {
+            return acceptResult( result ? ResultWas::Ok : ResultWas::ExpressionFailed );
         }
 
-        virtual void StartTesting(){}
+        virtual ResultAction::Value acceptResult( ResultWas::OfType result ) {
+            m_currentResult.setResultType( result );
+            return actOnCurrentResult();
+        }
 
-        virtual void StartGroup( const std::string& groupName ) {
-            m_statsForSuites.push_back( Stats( groupName ) );
-            m_currentStats = &m_statsForSuites.back();
+        virtual ResultAction::Value acceptExpression( const ResultInfoBuilder& resultInfo ) {
+            m_currentResult = resultInfo;
+            return actOnCurrentResult();
         }
 
-        virtual void EndGroup( const std::string&, const Totals& totals ) {
-            m_currentStats->m_testsCount = totals.assertions.total();
-            m_currentStats = &m_testSuiteStats;
+        virtual void acceptMessage( const std::string& msg ) {
+            m_currentResult.setMessage( msg );
         }
 
-        virtual void StartSection( const std::string&, const std::string& ){}
+        virtual void testEnded( const ResultInfo& result ) {
+            if( result.getResultType() == ResultWas::Ok ) {
+                m_totals.assertions.passed++;
+            }
+            else if( !result.ok() ) {
+                m_totals.assertions.failed++;
 
-        virtual void EndSection( const std::string&, const Counts& ){}
+                std::vector<ResultInfo>::const_iterator it = m_info.begin();
+                std::vector<ResultInfo>::const_iterator itEnd = m_info.end();
+                for(; it != itEnd; ++it )
+                    m_reporter->Result( *it );
+                m_info.clear();
+            }
 
-        virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
-            m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getName() ) );
+            if( result.getResultType() == ResultWas::Info )
+                m_info.push_back( result );
+            else
+                m_reporter->Result( result );
         }
 
-        virtual void Result( const Catch::ResultInfo& resultInfo ) {
-            if( resultInfo.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults ) {
-                TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
-                TestStats stats;
-                std::ostringstream oss;
-                if( !resultInfo.getMessage().empty() )
-                    oss << resultInfo.getMessage() << " at ";
-                oss << SourceLineInfo( resultInfo.getFilename(), resultInfo.getLine() );
-                stats.m_content = oss.str();
-                stats.m_message = resultInfo.getExpandedExpression();
-                stats.m_resultType = resultInfo.getTestMacroName();
+        virtual bool sectionStarted (
+            const std::string& name,
+            const std::string& description,
+            const SourceLineInfo& lineInfo,
+            Counts& assertions
+        )
+        {
+            std::ostringstream oss;
+            oss << name << "@" << lineInfo;
 
-                switch( resultInfo.getResultType() ) {
-                    case ResultWas::ThrewException:
-                        stats.m_element = "error";
-                        m_currentStats->m_errorsCount++;
-                        break;
-                    case ResultWas::Info:
-                        stats.m_element = "info"; // !TBD ?
-                        break;
-                    case ResultWas::Warning:
-                        stats.m_element = "warning"; // !TBD ?
-                        break;
-                    case ResultWas::ExplicitFailure:
-                        stats.m_element = "failure";
-                        m_currentStats->m_failuresCount++;
-                        break;
-                    case ResultWas::ExpressionFailed:
-                        stats.m_element = "failure";
-                        m_currentStats->m_failuresCount++;
-                        break;
-                    case ResultWas::Ok:
-                        stats.m_element = "success";
-                        break;
-                    case ResultWas::Unknown:
-                    case ResultWas::FailureBit:
-                    case ResultWas::Exception:
-                    case ResultWas::DidntThrowException:
-                    default:
-                        stats.m_element = "unknown";
-                        break;
-                }
-                testCaseStats.m_testStats.push_back( stats );
-            }
+            if( !m_runningTest->addSection( oss.str() ) )
+                return false;
+
+            m_currentResult.setLineInfo( lineInfo );
+            m_reporter->StartSection( name, description );
+            assertions = m_totals.assertions;
+
+            return true;
         }
 
-        virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string& stdOut, const std::string& stdErr ) {
-            if( !stdOut.empty() )
-                m_stdOut << stdOut << "\n";
-            if( !stdErr.empty() )
-                m_stdErr << stdErr << "\n";
+        virtual void sectionEnded( const std::string& name, const Counts& prevAssertions ) {
+            m_runningTest->endSection( name );
+            m_reporter->EndSection( name, m_totals.assertions - prevAssertions );
         }
 
-        virtual void Aborted() {
-            // !TBD
+        virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
+            m_scopedInfos.push_back( scopedInfo );
         }
 
-        virtual void EndTesting( const Totals& ) {
-            std::ostream& str = m_config.stream;
-            {
-                XmlWriter xml( str );
+        virtual void popScopedInfo( ScopedInfo* scopedInfo ) {
+            if( m_scopedInfos.back() == scopedInfo )
+                m_scopedInfos.pop_back();
+        }
 
-                if( m_statsForSuites.size() > 0 )
-                    xml.startElement( "testsuites" );
+        virtual bool shouldDebugBreak() const {
+            return m_config.shouldDebugBreak();
+        }
 
-                std::vector<Stats>::const_iterator it = m_statsForSuites.begin();
-                std::vector<Stats>::const_iterator itEnd = m_statsForSuites.end();
+        virtual std::string getCurrentTestName() const {
+            return m_runningTest
+                ? m_runningTest->getTestCaseInfo().getName()
+                : "";
+        }
 
-                for(; it != itEnd; ++it ) {
-                    XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
-                    xml.writeAttribute( "name", it->m_name );
-                    xml.writeAttribute( "errors", it->m_errorsCount );
-                    xml.writeAttribute( "failures", it->m_failuresCount );
-                    xml.writeAttribute( "tests", it->m_testsCount );
-                    xml.writeAttribute( "hostname", "tbd" );
-                    xml.writeAttribute( "time", "tbd" );
-                    xml.writeAttribute( "timestamp", "tbd" );
+        virtual const ResultInfo* getLastResult() const {
+            return &m_lastResult;
+        }
 
-                    OutputTestCases( xml, *it );
-                }
+    private:
 
-                xml.scopedElement( "system-out" ).writeText( trim( m_stdOut.str() ) );
-                xml.scopedElement( "system-err" ).writeText( trim( m_stdErr.str() ) );
-            }
+        bool aborting() const {
+            return m_totals.assertions.failed == static_cast<std::size_t>( m_config.getCutoff() );
         }
 
-        void OutputTestCases( XmlWriter& xml, const Stats& stats ) {
-            std::vector<TestCaseStats>::const_iterator it = stats.m_testCaseStats.begin();
-            std::vector<TestCaseStats>::const_iterator itEnd = stats.m_testCaseStats.end();
-            for(; it != itEnd; ++it ) {
-                xml.writeBlankLine();
-                xml.writeComment( "Test case" );
+        ResultAction::Value actOnCurrentResult() {
+            testEnded( m_currentResult );
+            m_lastResult = m_currentResult;
 
-                XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
-                xml.writeAttribute( "classname", it->m_className );
-                xml.writeAttribute( "name", it->m_name );
-                xml.writeAttribute( "time", "tbd" );
+            m_currentResult = ResultInfoBuilder();
 
-                OutputTestResult( xml, *it );
+            ResultAction::Value action = ResultAction::None;
+
+            if( !m_lastResult.ok() ) {
+                action = ResultAction::Failed;
+                if( shouldDebugBreak() )
+                    action = (ResultAction::Value)( action | ResultAction::Debug );
+                if( aborting() )
+                    action = (ResultAction::Value)( action | ResultAction::Abort );
             }
+            return action;
         }
 
-        void OutputTestResult( XmlWriter& xml, const TestCaseStats& stats ) {
-            std::vector<TestStats>::const_iterator it = stats.m_testStats.begin();
-            std::vector<TestStats>::const_iterator itEnd = stats.m_testStats.end();
-            for(; it != itEnd; ++it ) {
-                if( it->m_element != "success" ) {
-                    XmlWriter::ScopedElement e = xml.scopedElement( it->m_element );
-
-                    xml.writeAttribute( "message", it->m_message );
-                    xml.writeAttribute( "type", it->m_resultType );
-                    if( !it->m_content.empty() )
-                        xml.writeText( it->m_content );
+        void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
+            try {
+                m_runningTest->reset();
+                if( m_reporter->shouldRedirectStdout() ) {
+                    StreamRedirect coutRedir( std::cout, redirectedCout );
+                    StreamRedirect cerrRedir( std::cerr, redirectedCerr );
+                    m_runningTest->getTestCaseInfo().invoke();
+                }
+                else {
+                    m_runningTest->getTestCaseInfo().invoke();
                 }
+                m_runningTest->ranToCompletion();
+            }
+            catch( TestFailureException& ) {
+                // This just means the test was aborted due to failure
+            }
+            catch(...) {
+                acceptMessage( getRegistryHub().getExceptionTranslatorRegistry().translateActiveException() );
+                acceptResult( ResultWas::ThrewException );
             }
+            m_info.clear();
         }
 
     private:
-        ReporterConfig m_config;
-        bool m_currentTestSuccess;
+        IMutableContext& m_context;
+        RunningTest* m_runningTest;
+        ResultInfoBuilder m_currentResult;
+        ResultInfo m_lastResult;
 
-        Stats m_testSuiteStats;
-        Stats* m_currentStats;
-        std::vector<Stats> m_statsForSuites;
-        std::ostringstream m_stdOut;
-        std::ostringstream m_stdErr;
+        const Config& m_config;
+        Totals m_totals;
+        Ptr<IReporter> m_reporter;
+        std::vector<ScopedInfo*> m_scopedInfos;
+        std::vector<ResultInfo> m_info;
+        IRunner* m_prevRunner;
+        IResultCapture* m_prevResultCapture;
+        const IConfig* m_prevConfig;
     };
 
 } // end namespace Catch
@@ -4180,10 +4192,6 @@ namespace Catch {
 
 } // end namespace Catch
 
-// #included from: internal/catch_impl.hpp
-
-// Collect all the implementation files together here
-// These are the equivalent of what would usually be cpp files
 // #included from: catch_registry_hub.hpp
 
 // #included from: catch_test_case_registry_impl.hpp
@@ -4198,6 +4206,7 @@ namespace Catch {
     class TestRegistry : public ITestCaseRegistry {
     public:
         TestRegistry() : m_unnamedCount( 0 ) {}
+        virtual ~TestRegistry();
 
         virtual void registerTest( const TestCaseInfo& testInfo ) {
             if( testInfo.getName() == "" ) {
@@ -4250,6 +4259,7 @@ namespace Catch {
     public:
 
         FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
+        virtual ~FreeFunctionTestCase();
 
         virtual void invoke() const {
             m_fun();
@@ -4304,7 +4314,7 @@ namespace Catch {
 
     public:
 
-        ~ReporterRegistry() {
+        virtual ~ReporterRegistry() {
             deleteAllValues( m_factories );
         }
 
@@ -4946,6 +4956,37 @@ namespace Catch {
 
 } // end namespace Catch
 
+namespace Catch {
+    NonCopyable::~NonCopyable() {}
+    IShared::~IShared() {}
+    StreamBufBase::~StreamBufBase() {}
+    IContext::~IContext() {}
+    IResultCapture::~IResultCapture() {}
+    ITestCase::~ITestCase() {}
+    ITestCaseRegistry::~ITestCaseRegistry() {}
+    IRegistryHub::~IRegistryHub() {}
+    IMutableRegistryHub::~IMutableRegistryHub() {}
+    IExceptionTranslator::~IExceptionTranslator() {}
+    IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
+    IReporter::~IReporter() {}
+    IReporterFactory::~IReporterFactory() {}
+    IReporterRegistry::~IReporterRegistry() {}
+    BasicReporter::~BasicReporter() {}
+    IRunner::~IRunner() {}
+    IMutableContext::~IMutableContext() {}
+    IConfig::~IConfig() {}
+    XmlReporter::~XmlReporter() {}
+    JunitReporter::~JunitReporter() {}
+    TestRegistry::~TestRegistry() {}
+    FreeFunctionTestCase::~FreeFunctionTestCase() {}
+    IGeneratorInfo::~IGeneratorInfo() {}
+    IGeneratorsForTest::~IGeneratorsForTest() {}
+
+    void Config::dummy() {}
+
+}
+
+#pragma clang diagnostic pop
 #endif
 
 #ifdef CATCH_CONFIG_MAIN
@@ -5071,5 +5112,7 @@ int main (int argc, char * const argv[]) {
 
 using Catch::Detail::Approx;
 
+#pragma clang diagnostic pop
+
 #endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED