Patch to allow relative paths in QTest executables parsing with CMake

Daniel Calviño Sánchez danxuliu at gmail.com
Sat Dec 27 03:09:09 UTC 2008


Hi,

I have noticed a problem in the QTest plugin. If the tests added with
ADD_TEST macro in CTestTestfile.cmake don't include the full path to
the executable, the tests aren't recognized automatically by the
plugin (that is, when CMake manager is used in KDevelop project).

When KDE4_ADD_UNIT_TEST macro is used this is not a problem because
that macro automatically adds the full path to the executable when it
calls ADD_TEST. However, in Qt only projects, ADD_TEST can be used
just specifying the name of the test executable, without the full
path, as ctest does several checks to find the executables.

I have made a fix for this. First, veritas/CTestFileParser, in
KDevPlatform, should set the working directory in the information of
each parsed test. In order to test this I had to change a bit the
FilesystemAccessMock, as it didn't perform a "true" change of
directory, so the relative files weren't solved as expected. Then I
implemented a test with 3 CTestTestfile.cmake (a parent and two
siblings) to check that the tests in each directory had a right
working directory. I suppose that setting the working directory for
the tests doesn't break anything...

Now the changes needed in QTest plugin. Function findTargetFor in
plugins/xtest/qtest/kdevregister.cpp, in KDevelop, is used to filter
the tests so only those associated with a target in the project are
taken into account. To do that, it checks if the executable command is
associated to any project executable target item. But if the test was
specified with just the test executable name, it isn't found. So, in
that case, the working directory should be prepended to the executable
name.

In the attached patch, the command is resolved (if needed) to a full
path using the working directory. That would also manage arbitrary
relative paths, and not only test executable names.

In commit 901212
(http://websvn.kde.org/trunk/KDE/kdevelop/plugins/xtest/qtest/kdevregister.cpp?r1=901212&r2=901211&pathrev=901212),
the "executables" entry in Veritas configuration group was set to the
commands of the tests. I have modified it so it is also set to the
resolved path. However, I don't know what is that used for, as that
entry isn't used anywhere (when using CMake manager). That is, the
executables are written, but never read. The only place where they are
used is just to show them in the QTest configuration page... but as
they are ignored (they are parsed again every time) personally I
wouldn't show them in the configuration.

Moreover, with the patch, if the executable path isn't relative to the
working directory, but just a system wide executable (for example, to
execute valgrind), the executable entry would be wrongly set to
workingDirectory/valgrind (this isn't a problem in findTargetFor, as
there won't be a target for that executable and it will be ignored).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: saveWorkingDir.diff
Type: text/x-patch
Size: 10262 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20081227/884a263b/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resolvePath.diff
Type: text/x-patch
Size: 1082 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20081227/884a263b/attachment-0001.diff>


More information about the KDevelop-devel mailing list