Discovered unit-tests using bracket arguments and/or listed in files other than CTestTestFile.cmake

Authored by tnorth on Mar 11 2019, 8:26 AM.



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.

See also

Diff Detail

R32 KDevelop
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
tnorth created this revision.Mar 11 2019, 8:26 AM
Restricted Application added a project: KDevelop. · View Herald TranscriptMar 11 2019, 8:26 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald Transcript
tnorth requested review of this revision.Mar 11 2019, 8:26 AM
tnorth edited the summary of this revision. (Show Details)
mwolff requested changes to this revision.Mar 11 2019, 9:19 AM
mwolff added a subscriber: mwolff.

great! can we get a unit test for this? though I'm unsure if we ever revived the unit tests from our old cmake integration

I've some small style nits, but otherwise +1


then add this function here (with the style fixes mentioned above), and have importTestSuites defer to it via

QVector<Test> importTestSuites(const Path &buildDir)
    return importTestSuites(buildDir, QStringLiteral("CTestTestfile.cmake"));

const and lower-case the start


QString() or {} instead of empty string literal

265 ↗(On Diff #53636)

remove space after &, but add spaces around = and lower-case the cmakeTestFileName

looking below, it would probably be better to split this up, i.e. only keep the importTestSuites public that takes only a Path (i.e. the old API)

This revision now requires changes to proceed.Mar 11 2019, 9:19 AM
tnorth updated this revision to Diff 53713.Mar 12 2019, 9:48 AM

Include suggested fixes

tnorth marked 3 inline comments as done.Mar 12 2019, 9:49 AM

Regarding the unit-test, I've seen a similar one at plugins/cmake/tests/manual/parentheses_in_test_arguments/, one could do something like that, but I don't really see here arguments passed to the test are checked... (only had a quick look).


Do you want importTestSuites(buildDir, QStringLiteral("CTestTestfile.cmake")) also exported in the .h file?

mwolff accepted this revision.Mar 12 2019, 8:14 PM

thanks, lgtm - I'll amend the last nits and apply it for you - if you give me full name and email address such that I can set you as the main author of this patch


style: remove spaces before;


style: move { to its own line for function bodies

This revision is now accepted and ready to land.Mar 12 2019, 8:14 PM
kfunk added a comment.Mar 13 2019, 4:13 PM

Note: It's Thibault North <>

That's right, thanks a lot!

This revision was automatically updated to reflect the committed changes.