[CMake] Bug in generation of CTestTestfile commands with test or directory names containing spaces

David Cole david.cole at kitware.com
Sun Dec 18 22:12:11 EST 2011


On Sun, Dec 18, 2011 at 7:34 PM,  <eddyaod at gmail.com> wrote:
> Greetings,
>
> I have noticed that it is possible to run in to problems with CMake
> when sub directories or test names contain spaces. CMake initially
> parses quote delimited strings correctly, however it writes them
> without quotes into the generated CTestTestfile.cmake files which then
> causes problems when CTest is run.
>
> Please find attached a small example and also a potential fix, in git
> patch format.
>
> To see the example in action, configure and generate a build using
> CMake with the "src" folder as source root, then try to run CTest
> within the build root. No tests can be found. There are actually 2
> issues with the results of CMake. Firstly, in CTestTestfile.cmake in
> the build root the command SUBDIRS(Sub Dir) is incorrect. If you
> change it to SUBDIRS("Sub Dir") there is still a problem with the
> ADD_TEST commands in the "Sub Dir" directory's CTestTestfile.cmake of
> the build. Again, the test name needs to be delimited with quotes.
> Once this is fixed to: ADD_TEST("Run Test" ... then CTest can
> correctly parse and run the specified test.
>
> The patch I have prepared simply wraps all test names and subdirectory
> names with quotes as they are written to the CTestTestFile. There may
> be more places where similar fixes would be appropriate if anyone
> knows of any.
>
> I hope someone might be able to review this issue.
>
> Finally, a big thank you to all involved with CMake for producing such
> a great development tool.
>
> Regards,
>
> Edmund Fokschaner
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

I started looking at this, but have not completed my review yet. There
are some other instances of add_test generation calls that will also
need quoting. There may be other places in ctest where it will be
unexpected that test names have spaces in them. Before I simply merge
this change in to 'next', I'd like to complete the review and figure
out where else we may need additional support.


Thanks,
David


More information about the CMake mailing list