<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-05-05 13:34 GMT+02:00 Sjaak Zwart <span dir="ltr"><<a href="mailto:sjaak10101@gmail.com" target="_blank">sjaak10101@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear all,<br><br></div><div>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++).<br><br>Currently, for performance tests I do:<br>    add_executable (mybenchmarks ${MYBENCHMARKS_CPP}<br></div><div>(as I don't want these to run by default)<br></div><div><br></div><div>While for unit tests I do:<br></div><div>    add_test (mytests mytests)<br></div><div>    add_executable (mytests ${MYTESTS_CPP})<br><br></div><div>I can then manually start the performance test by running the executable, and use 'make test' or 'ctest' to start the normal tests.<br><br></div><div>I wonder if I can do better, maybe there's standard support for this already?<br><br></div><div>Ideally, I think I would like to replace add_test by something like add_performance_test and then launch ctest with some special flag?<br><br></div><div>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?<br></div></div></blockquote><div><br></div><div>Yes you can do that.<br></div><div>You can run ctest using either:<br><br>  -L <regex>, --label-regex <regex><br>                              = Run tests with labels matching regular<br>                                expression.<br>  -R <regex>, --tests-regex <regex><br>                              = Run tests matching regular expression.<br>  -E <regex>, --exclude-regex <regex><br>                              = Exclude tests matching regular expression.<br>  -LE <regex>, --label-exclude <regex><br>                              = Exclude tests with labels matching regular<br>                                expression.<br><br></div><div>-R -E works with the name of the test<br></div><div>whereas -L and -LE work with the LABEL of a test that may be set using<br><br></div><div>set_property(TEST mybenchmarks PROPERTY LABELS perf)<br>set_property(TEST mytests PROPERTY LABELS unit)<br><br></div><div>note that<br></div><div>"make test" will run all the test <br></div><div>whereas<br><br></div><div>ctest -R/-E/-L/-LE  .... will run the appropriate subset.<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div><br></div><div>Thanks,<br></div><div>Sjaak.<br></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div>
</div></div>