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

Fix bug where `catch_discover_tests` fails when no `TEST_CASE`s are present

Commit
76f70b1403dbc0781216f49e20e45b71f7eccdd8
Author
Chris Thrasher ·
Parents
914aeecfe23b

Files · Download .tar.gz

Changes

 extras/CatchAddTests.cmake | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/extras/CatchAddTests.cmake b/extras/CatchAddTests.cmake
index ceaf8652..25342139 100644
--- a/extras/CatchAddTests.cmake
+++ b/extras/CatchAddTests.cmake
@@ -143,6 +143,12 @@ function(catch_discover_tests_impl)
   # Speed-up reparsing by cutting away unneeded parts of JSON.
   string(JSON test_listing GET "${listing_output}" "listings" "tests")
   string(JSON num_tests LENGTH "${test_listing}")
+
+  # Exit early if no tests are detected
+  if(num_tests STREQUAL "0")
+    return()
+  endif()
+
   # CMake's foreach-RANGE is inclusive, so we have to subtract 1
   math(EXPR num_tests "${num_tests} - 1")