Created attachment 118651 [details] diff for importTestSuite.{cpp,h} SUMMARY Unit-tests produced via gtest_discover_tests() are not discovered by KDevelop. There seem to be two reasons for that: - KDevelop is able to discover unit-tests from CMake files given that: 1) There is a CTestTestfile.cmake file in the root of the build directory 2) if that file contains "subdir" directives, unit-tests are searched in ${subdir}/CTestTestfile.cmake (recursively). It seems (?) that include() directives are not followed. - Bracket arguments ( https://cmake.org/cmake/help/v3.14/manual/cmake-language.7.html#bracket-argument ) are used to pass command-line arguments to the unit-tests. It seems that the parser can't interpret those (?). STEPS TO REPRODUCE 1. Create executable targets with CMake, and pass them to gtest_discover_tests() with some EXTRA_ARGS directives 2. Run Kdevelop on that project OBSERVED RESULT The unit-test view is empty EXPECTED RESULT Unit-tests are shown SOFTWARE/OS VERSIONS Linux/KDE Plasma: Fedora 29 (available in About System) KDE Plasma Version: 5.14.5 KDE Frameworks Version: 5.55.0 Qt Version: 5.11.3 ADDITIONAL INFORMATION CTestTestfile.cmake may contain: include("/home/.../build/unittests/test_foo[1]_include.cmake") The import seems to skip that. A minimal fix is attached to follow include() directives.
Git commit d5e3e27bb2720d84adda95de07a728a9e61c866f by Milian Wolff, on behalf of Thibault North. Committed on 20/03/2019 at 18:27. Pushed by mwolff into branch 'master'. CMake: discover more unit tests Discover unit-tests using bracket arguments and/or listed in files other than CTestTestFile.cmake: When using gtest_discover_tests(), add_test() directives are present in various .cmake files. To date, Kdevelop searches for unit-tests does not follow include() directives present in the main CTestTestfile.cmake, leading to no unit-tests being shown. Additionally, the bracket arguments of CMake is not enabled for parsing tests arguments. This patch enables them, and follows include() directives. Reviewers: apol, kfunk, mwolff Reviewed By: mwolff Subscribers: mwolff, kdevelop-devel Tags: #kdevelop Differential Revision: https://phabricator.kde.org/D19673 M +11 -4 plugins/cmake/cmakeutils.cpp M +1 -0 plugins/cmake/parser/cmakelistsparser.cpp https://invent.kde.org/kde/kdevelop/commit/d5e3e27bb2720d84adda95de07a728a9e61c866f