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

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

Details

Summary

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 https://bugs.kde.org/show_bug.cgi?id=405225

Diff Detail

Repository
R32 KDevelop
Lint
Lint Skipped
Unit
Unit Tests Skipped
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

plugins/cmake/cmakeutils.cpp
694

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"));
}
696

const and lower-case the start

714

QString() or {} instead of empty string literal

plugins/cmake/cmakeutils.h
265

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).

plugins/cmake/cmakeutils.cpp
694

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

plugins/cmake/cmakeutils.cpp
696

style: remove spaces before;

738

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 <thibault.north@gmail.com>

That's right, thanks a lot!

This revision was automatically updated to reflect the committed changes.