asked 2011-04-26 04:59:37 -0500Julius
I am using Google Test Framework for running tests for my ROS package. I compile and link my test executable using
and run the tests by issuing command
It happens, though, that other executables in that package are linked as well. Since I am usually developing test first and then adapting the source to fit that test, it is very annoying to wait for a long time for linking targets that are not required for running the test.
I do not want to hack the build system (
view $(rospack find mk)/cmake.mk), this being inadequate and downright dangerous. Any ideas or option I have overlooked to build only the executable added with
answered 2011-04-27 08:31:38 -0500Brian Gerkey
There's no way to do this currently, and I don't think it'll be worthwhile to implement it. In your situation, I would do one of two things:
CMakeLists.txtduring test development; or
foo, put tests in
Btw, it's awesome that you're putting such effort into writing tests!
test target can run two kinds of tests: unit tests (C++ or Python) and
rostests. Unit tests, which it sounds like you're using, are generally self-contained (but not always; see below). On the other hand, it's common to use a
rostest to verify the functionality of executables that are built by the package (e.g., see test for topic_tools/relay).
To support your use case, we'd need to define two categories of tests: one that wants all the executables built, and one that doesn't, with API hooks to allow the developer to say which kind of test is being declared. We'd further have to segregate libraries from executables, to allow them to be built separately (they're currently both attached to the
ALL target). And then we'd likely have to retrofit existing packages that use unit tests to verify executables via fork/exec (e.g., see the pyunit-based rospack test suite).
answered 2011-04-26 05:27:10 -0500Julius
My current workaround is to duplicate CMakeLists.txt, leaving all but the test executable and then taking either one for linking test and other build executables. It's nasty though and it might sometimes happen that your original CMakeLists.txt gets lost when stopping the script in the middle of the build process.
#!/usr/bin/env bash cp CMakeLists.txt CMakeLists.txt.backup cp CMakeListsTest.txt CMakeLists.txt if [ "$1" = "tests" ]; then make tests elif [ "$1" = "test" ]; then make test else cat <<HELP Usage: test.bash TARGET Available targets: tests -- compile and link tests test -- run tests HELP fi mv CMakeLists.txt.backup CMakeLists.txt
Hope this answer gets voted down soon and replaced by a better solution!
Asked: 2011-04-26 04:59:37 -0500
Seen: 165 times
Last updated: Apr 27 '11