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

Minimal changes to get iTchRunner to work again

Commit
daedf8ff5ff927c4a7b4033a3c2379ea136529c7
Author
Phil Nash ·
Parents
ff03cdf2b25b

Files · Download .tar.gz

Changes

 .gitignore                                         |  3 +-
 .../iTchRunner/internal/iTchRunnerMainView.h       | 62 +++++++++++++++++-----
 .../iTchRunner/internal/iTchRunnerReporter.h       |  8 +--
 projects/runners/iTchRunner/itChRunnerMain.mm      |  1 +
 4 files changed, 58 insertions(+), 16 deletions(-)

diff --git a/.gitignore b/.gitignore
index ccd16f6c..b3bb2b8c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@ Breakpoints.xcbkptlist
 projects/VS2010/TestCatch/_UpgradeReport_Files/
 projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj.filters
 projects/VisualStudio/TestCatch/UpgradeLog.XML
-UpgradeLog.XML
\ No newline at end of file
+UpgradeLog.XML
+projects/XCode4/iOSTest/Build/Intermediates/PrecompiledHeaders
diff --git a/projects/runners/iTchRunner/internal/iTchRunnerMainView.h b/projects/runners/iTchRunner/internal/iTchRunnerMainView.h
index 12f9c5db..5cc8802b 100644
--- a/projects/runners/iTchRunner/internal/iTchRunnerMainView.h
+++ b/projects/runners/iTchRunner/internal/iTchRunnerMainView.h
@@ -75,40 +75,78 @@
  
 }
 
+// This is a copy & paste from Catch::Runner2 to get us bootstrapped (this is due to all be
+// replaced anyway)
+inline Catch::Totals runTestsForGroup( Catch::Runner& context, const Catch::TestCaseFilters& filterGroup ) {
+    using namespace Catch;
+    Totals totals;
+    std::vector<TestCase>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
+    std::vector<TestCase>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
+    int testsRunForGroup = 0;
+    for(; it != itEnd; ++it ) {
+        if( filterGroup.shouldInclude( *it ) ) {
+            testsRunForGroup++;
+
+            if( context.aborting() )
+                break;
+
+            totals += context.runTest( *it );
+        }
+    }
+    if( testsRunForGroup == 0 )
+        std::cerr << "\n[No test cases matched with: " << filterGroup.getName() << "]" << std::endl;
+    return totals;
+
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 -(void) actionSheet: (UIActionSheet*) sheet clickedButtonAtIndex: (NSInteger) index
 {
     Catch::Config config;
-    config.setReporter( new Catch::iTchRunnerReporter( self ) );
-    Catch::Runner runner( config );
-    
-    config.getReporter()->StartGroup( "" );
-    runner.runAll( true );
-    config.getReporter()->EndGroup( "", runner.getTotals() );
+    Catch::IReporter* reporter = new Catch::iTchRunnerReporter( self );
+    Catch::LegacyReporterAdapter* reporterAdapter = new Catch::LegacyReporterAdapter( reporter, Catch::ReporterConfig( config.stream(), config.data() ) );
+    Catch::Runner runner( config, reporterAdapter );
+
+
+    std::vector<Catch::TestCaseFilters> filterGroups;
+    Catch::TestCaseFilters filterGroup( "" );
+    filterGroups.push_back( filterGroup );
+
+    Catch::Totals totals;
+
+    std::vector<Catch::TestCaseFilters>::const_iterator it = filterGroups.begin();
+    std::vector<Catch::TestCaseFilters>::const_iterator itEnd = filterGroups.end();
+
+    for(; it != itEnd && !runner.aborting(); ++it ) {
+        runner.testGroupStarting( it->getName() );
+        totals += runTestsForGroup( runner, *it );
+        runner.testGroupEnded( it->getName(), totals );
+    }
+
 
-    if( runner.getTotals().assertions.failed == 0 )
+    if( totals.assertions.failed == 0 )
     {
         NSLog( @"no failures" );
-        if( runner.getTotals().assertions.passed > 0 )
+        if( totals.assertions.passed > 0 )
             appName.textColor = [[UIColor alloc] initWithRed:0.35 green:1 blue:0.35 alpha:1];
     }
     else
     {
-        NSLog( @"%lu failures", runner.getTotals().assertions.failed );
+        NSLog( @"%lu failures", totals.assertions.failed );
         appName.textColor = [[UIColor alloc] initWithRed:1 green:0.35 blue:0.35 alpha:1];
     }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
--(void) testWasRun: (const Catch::ResultInfo*) pResultInfo
+-(void) testWasRun: (const Catch::AssertionResult*) pResultInfo
 {
-    const Catch::ResultInfo& resultInfo = *pResultInfo;
+    const Catch::AssertionResult& resultInfo = *pResultInfo;
     std::ostringstream oss;
     
     if( resultInfo.hasExpression() )
     {
         oss << resultInfo.getExpression();
-        if( resultInfo.ok() )
+        if( resultInfo.isOk() )
             oss << " succeeded";
         else
             oss << " failed";
diff --git a/projects/runners/iTchRunner/internal/iTchRunnerReporter.h b/projects/runners/iTchRunner/internal/iTchRunnerReporter.h
index 08bd1aac..a7adf866 100644
--- a/projects/runners/iTchRunner/internal/iTchRunnerReporter.h
+++ b/projects/runners/iTchRunner/internal/iTchRunnerReporter.h
@@ -13,7 +13,7 @@
 
 @protocol iTchRunnerDelegate
 
--(void) testWasRun: (const Catch::ResultInfo*) result;    
+-(void) testWasRun: (const Catch::AssertionResult*) result;    
 
 @end
 
@@ -87,7 +87,7 @@ namespace Catch
         ///////////////////////////////////////////////////////////////////////////
         virtual void Result
         (
-            const ResultInfo& result
+            const AssertionResult& result
         )
         {
             [m_delegate testWasRun: &result];
@@ -102,7 +102,9 @@ namespace Catch
         virtual void EndSection( const std::string&, const Counts& ){}
         virtual void EndTestCase( const TestCaseInfo&, const Totals&, const std::string&, const std::string& ){}
         virtual void Aborted() {}
-        
+        virtual void NoAssertionsInSection( std::string const& sectionName ) {}
+        virtual void NoAssertionsInTestCase( std::string const& testName ) {}
+
     private:
         Totals m_totals;
         
diff --git a/projects/runners/iTchRunner/itChRunnerMain.mm b/projects/runners/iTchRunner/itChRunnerMain.mm
index a28bc756..cac5faec 100644
--- a/projects/runners/iTchRunner/itChRunnerMain.mm
+++ b/projects/runners/iTchRunner/itChRunnerMain.mm
@@ -6,6 +6,7 @@
 //  Copyright Two Blue Cubes Ltd 2011. All rights reserved.
 //
 
+#define CATCH_CONFIG_RUNNER
 #include "catch.hpp"
 #import "internal/iTchRunnerAppDelegate.h"