[CMake] Subset testing with CTest

Leif Walsh leif.walsh at gmail.com
Wed Sep 12 14:21:58 EDT 2012


I prefix test names with the name of the component they test, so

a/tests/CMakeLists.txt:
add_test(a/test_foo test_foo)

b/tests/CMakeLists.txt:
add_test(b/test_foo test_foo)

Then, ctest -R '^a/' from toplevel works. 

Sent from my iPhone

On Sep 12, 2012, at 14:12, Robert Dailey <rcdailey.lists at gmail.com> wrote:

> The source repository at our company is structured for two products.
> Both products have a large amount of shared targets, but there are
> certain subdirectories in the tree that are product-specific. Each of
> the product-specific targets have their own unit tests (and all common
> targets have them as well).
> 
> When I want to build Product A, all I have to do is CD into product
> A's subdirectory and initiate a build from there. I'd like a similar
> feature for testing -- depending on which subdirectory we are in, we
> can determine what to build, what to test.
> 
> I was looking over the information on the CMake wiki here:
> http://cmake.org/Wiki/CMake/Testing_With_CTest
> 
> There is a section on specifying subsets. I can use regular
> expressions or test indices, neither of which will work for our case.
> There needs to be a way to specify tests for a single product.
> 
> Right now the only thing we can do is run "ctest -D Experimental" at
> the root, but this builds and tests both products at once. I want to
> be able to only build and test Product A. Can I do this now? Is there
> some workaround I can use, or perhaps a feature I'm not aware of?
> --
> 
> 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


More information about the CMake mailing list