2015-05-05 13:34 GMT+02:00 Sjaak Zwart <sjaak10...@gmail.com>: > Dear all, > > Could somebody give me some advice on how unit tests and performance tests > can/should be organized? I'm quite new to cmake (and c++). > > Currently, for performance tests I do: > add_executable (mybenchmarks ${MYBENCHMARKS_CPP} > (as I don't want these to run by default) > > While for unit tests I do: > add_test (mytests mytests) > add_executable (mytests ${MYTESTS_CPP}) > > I can then manually start the performance test by running the executable, > and use 'make test' or 'ctest' to start the normal tests. > > I wonder if I can do better, maybe there's standard support for this > already? > > Ideally, I think I would like to replace add_test by something like > add_performance_test and then launch ctest with some special flag? > > Another idea perhaps, maybe I could use a regular expression to run only > the performance tests, i.e., something like *PerfTest. But could I then > also run the unit tests still, i.e., everything that doesn't match > *PerfTest? >
Yes you can do that. You can run ctest using either: -L <regex>, --label-regex <regex> = Run tests with labels matching regular expression. -R <regex>, --tests-regex <regex> = Run tests matching regular expression. -E <regex>, --exclude-regex <regex> = Exclude tests matching regular expression. -LE <regex>, --label-exclude <regex> = Exclude tests with labels matching regular expression. -R -E works with the name of the test whereas -L and -LE work with the LABEL of a test that may be set using set_property(TEST mybenchmarks PROPERTY LABELS perf) set_property(TEST mytests PROPERTY LABELS unit) note that "make test" will run all the test whereas ctest -R/-E/-L/-LE .... will run the appropriate subset. > > Thanks, > Sjaak. > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake > -- Eric
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake