Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Defining a dependency for (a Python) add_rostest call?

I have a unit test written in Python that depends on a package that generates messages. If I run catkin_make run_tests --only-pkg-with-deps my_package, the test fails because it can't find the message modules. (If I run catkin_make --only-pkg-with-deps my_package before running the tests, the tests pass because the messages are generated.)

Without a proper/obvious CMake target (because Python), what's the preferred way to force catkin/cmake to build the messages before running the tests? I don't want to have to build everything first, as I believe CMake targets should be self-sufficient.

My current approach, though hacky, is to make my rostest stanza look like this:

if(CATKIN_ENABLE_TESTING)
    find_package(rostest REQUIRED)
    find_package(my_msgs REQUIRED)

    add_rostest(tests/my_test.test)
    add_dependencies(_run_tests_my_package_rostest_test_my_test.test ${my_msgs_EXPORTED_TARGETS})
endif()