[CMake] Building and executing tests when building updated libraries

David Cole david.cole at kitware.com
Tue Feb 21 13:37:06 EST 2012


On Tue, Feb 21, 2012 at 1:27 PM, Robert Dailey <rcdailey at gmail.com> wrote:

> Hi,
>
> I'm using Visual Studio as my generator for my CMake projects. As of right
> now, I make my tests depend on the libraries they test. So for example,
> tests named:
>
> test_thingA
> test_thingB
>
> will all depend on library:
>
> libfoo.lib
>
> When I build target "libfoo" in visual studio, it would be nice to have
> all dependent tests build as well, and have them each execute.
>
> The goal for all of this is to make it as convenient as possible for
> developers on my team to RUN TESTS on their code before they submit to
> version control. I want to make it automated, so when they rebuild the
> library, the testing automatically happens. I'd also obviously create an
> option in cmake cache to turn this automation off should it become too
> annoying.
>
> If this isn't a good idea, can someone recommend a good workflow for
> running tests locally prior to checking in source code?
>
> ---------
> Robert Dailey
>
> --
>
> 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
>


If you're using add_test in your CMakeLists files, then the perfect way to
prove that the tests all work on a developer's machine is for him or her to
run:

  ctest -D Experimental

after making local mods, and before pushing the changes to your source
control system.

That will configure, build all and run all the tests. And submit the
results to your CDash server so that is public evidence that he actually
did run the tests, and hopefully that they all passed on his machine at
least.

You can also restrict the set of tests that run using -R or -I or -L on the
ctest command line, although, you should strive to have your test suite be
brief enough that it's not painful for folks to run the full test suite
prior to checkin.


HTH,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120221/a5b3cd87/attachment-0001.htm>


More information about the CMake mailing list