Skip to content

Commit f4e83da

Browse files
solarispikahorenmar
authored andcommitted
Fix catch_discover_tests PRE_TEST failure with zero discoverable tests
When using catch_discover_tests() with DISCOVERY_MODE PRE_TEST and a multi-config generator (e.g. Ninja Multi-Config), if a test target has zero discoverable tests (e.g. all tests tagged with [.]), ctest fails: CMake Error: include could not find requested file: .../test-hidden-b12d07c_tests-Release.cmake The early return added in #2962 (76f70b1) correctly prevented a JSON parsing crash for zero tests, but skipped writing the ctest file. The PRE_TEST include script unconditionally includes this file, so the missing file causes a hard error that aborts all test discovery. Write an empty file before returning early so the include always succeeds.
1 parent 572f96b commit f4e83da

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

extras/CatchAddTests.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ function(catch_discover_tests_impl)
146146

147147
# Exit early if no tests are detected
148148
if(num_tests STREQUAL "0")
149+
file(WRITE "${_CTEST_FILE}" "")
149150
return()
150151
endif()
151152

0 commit comments

Comments
 (0)