Skip to content

Commit 76f70b1

Browse files
committed
Fix bug where catch_discover_tests fails when no TEST_CASEs are present
1 parent 914aeec commit 76f70b1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

extras/CatchAddTests.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ function(catch_discover_tests_impl)
143143
# Speed-up reparsing by cutting away unneeded parts of JSON.
144144
string(JSON test_listing GET "${listing_output}" "listings" "tests")
145145
string(JSON num_tests LENGTH "${test_listing}")
146+
147+
# Exit early if no tests are detected
148+
if(num_tests STREQUAL "0")
149+
return()
150+
endif()
151+
146152
# CMake's foreach-RANGE is inclusive, so we have to subtract 1
147153
math(EXPR num_tests "${num_tests} - 1")
148154

0 commit comments

Comments
 (0)