Skip to content

GoogleTest: Avoid silent failures of dynamic test discovery

Moritz Haase requested to merge mh/googletest-script-file-path into master

The internal helper variable '_GOOGLETEST_DISCOVER_TESTS_SCRIPT' can have gone out-of-scope when 'gtest_discover_tests()' is called, depending on where the GoogleTest module is actually included. This leads to a silent failure of dynamic test discovery, since the custom post-build commands actually does nothing (it basically invokes 'cmake -P ""'). Ctest will then fail to run the tests, considering them to be 'not built'.

Fix this by converting the variable holding the path to the script file to a CACHE one that is always available, independent of scope.

Merge request reports