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

Move debug break out of tests, speeds up compilation time

This is hidden behind CATCH_CONFIG_FAST_COMPILE
Commit
7b13a8f85a0fb7d99759591b01539d6d0202f383
Author
Martin Hořeňovský ·
Parents
6da5e0862a19

Files · Download .tar.gz

Changes

 include/internal/catch_capture.hpp        | 11 ++++++++++-
 include/internal/catch_result_builder.hpp |  9 +++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index 04be7016..30a5b8da 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -18,6 +18,14 @@
 #include "catch_compiler_capabilities.h"
 
 
+#if defined(CATCH_CONFIG_FAST_COMPILE)
+///////////////////////////////////////////////////////////////////////////////
+// We can speedup compilation significantly by breaking into debugger lower in
+// the callstack, because then we don't have to expand CATCH_BREAK_INTO_DEBUGGER
+// macro in each assertion
+#define INTERNAL_CATCH_REACT( resultBuilder ) \
+    resultBuilder.react();
+#else
 ///////////////////////////////////////////////////////////////////////////////
 // In the event of a failure works out if the debugger needs to be invoked
 // and/or an exception thrown and takes appropriate action.
@@ -25,7 +33,8 @@
 // source code rather than in Catch library code
 #define INTERNAL_CATCH_REACT( resultBuilder ) \
     if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \
-    resultBuilder.react();
+    resultBuilder.react(); 
+#endif
 
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/include/internal/catch_result_builder.hpp b/include/internal/catch_result_builder.hpp
index 7bb2cdc2..4e093347 100644
--- a/include/internal/catch_result_builder.hpp
+++ b/include/internal/catch_result_builder.hpp
@@ -99,6 +99,15 @@ namespace Catch {
     }
 
     void ResultBuilder::react() {
+#if defined(CATCH_CONFIG_FAST_COMPILE)
+        if (m_shouldDebugBreak) {
+            ///////////////////////////////////////////////////////////////////
+            // To inspect the state during test, you need to go one level up the callstack
+            // To go back to the test and change execution, jump over the throw statement
+            ///////////////////////////////////////////////////////////////////
+            CATCH_BREAK_INTO_DEBUGGER();
+        }
+#endif
         if( m_shouldThrow )
             throw Catch::TestFailureException();
     }