ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Defining a dependency for (a Python) add_rostest call?

asked 2015-11-06 08:42:01 -0500

dustingooding gravatar image

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()
edit retag flag offensive close merge delete

Comments

Maybe this issue will help? https://github.com/ros/ros_comm/issue...

William gravatar image William  ( 2015-11-06 18:00:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-11-06 18:06:48 -0500

William gravatar image

Looks like you can pass the message target dependencies to the add_rostest(...) call using the DEPENDENCIES target:

http://docs.ros.org/api/catkin/html/h...

So your code would look like:

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

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

I think that should work, but I haven't tried it myself.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-06 08:42:01 -0500

Seen: 523 times

Last updated: Nov 06 '15