Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/extras
diff options
context:
space:
mode:
authorChris Thrasher2025-03-11 20:37:17 -0600
committerChris Thrasher2025-03-12 14:03:56 -0600
commit76f70b1403dbc0781216f49e20e45b71f7eccdd8 (patch)
tree98a80eb02c3c43aeeb868d9952768950fb58df47 /extras
parent914aeecfe23b1e16af6ea675a4fb5dbd5a5b8d0a (diff)
downloadcatch3-76f70b1403dbc0781216f49e20e45b71f7eccdd8.tar.gz
Fix bug where `catch_discover_tests` fails when no `TEST_CASE`s are present
Diffstat (limited to 'extras')
-rw-r--r--extras/CatchAddTests.cmake6
1 files changed, 6 insertions, 0 deletions
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")