Ask Your Question
0

Automatically run tests on ROS build farm for pure cmake project

asked 2018-07-07 10:33:16 -0600

updated 2018-07-27 07:47:25 -0600

I'm hosting some pure cmake projects ifopt and towr (not dependent on catkin) on the ROS build farm, for which I generate some unit test in my CMakeLists.txt similar to:

find_package(GTest)
add_executable(test my_test.cpp)  
target_link_libraries(test ${GTEST_BOTH_LIBRARIES} pthread)
add_test(test test)

I can run these with make test after a non-catkin build, this works fine.

How can I tell the ROS build farm (which seems to be internally calling catkin_make run_tests) to run that gtest binary as well after building? (jenkins-log)

I don't want to catkinize my project, which would allow me to use catkin_add_gtest. I want to keep allowing the cd build && cmake .. pure cmake build for users that don't have catkin installed.

Any help would be greatly appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-07-10 11:08:06 -0600

Dirk Thomas gravatar image

The ros_buildfarm first builds a workspace, then builds the tests and runs the tests.

Since catkin_make_isolated is used which just passes make targets It relies on the CMake packages to have a tests target to build tests as well as a run_tests target to run the tests. For a plain CMake package you need to make sure to create these targets and make sure run_tests actually runs the tests. As you have already experienced implementing a similar logic as provided by catkin to run tests is not straight forward.

A modified version of the ros_buildfarm ( https://github.com/ros-infrastructure... ) used for ROS 2 uses colcon instead of catkin_make_isolated for build the workspace and running the tests. The "big" difference is that it doesn't rely on a specific custom target to exist but runs the tests by invoking ctest instead. That would immediately work for plain CMake package which use CTest. It is unclear though at the moment when or even if the buildfarm for ROS 1 will switch to use this new build tool.

Maybe you can create a run_tests target in your CMake package which just invokes ctest (just speculating here - haven't tried it)?

edit flag offensive delete link more
0

answered 2018-07-07 15:02:50 -0600

demmeln gravatar image

Looks for the log like it does not run make run_tests for pure cmake packages.

But it does look like it runs

02:12:27 ==> cmake /tmp/catkin_workspace/src/ifopt -DCMAKE_INSTALL_PREFIX=/tmp/catkin_workspace/devel_isolated/ifopt -DCATKIN_ENABLE_TESTING=1 -DCATKIN_SKIP_TESTING=0 -DCATKIN_TEST_RESULTS_DIR=/tmp/catkin_workspace/test_results -G Unix Makefiles in '/tmp/catkin_workspace/build_isolated/ifopt/devel'

Maybe you can add cmake logic to add running you tests to the default targets if CATKIN_ENABLE_TESTING=1?

But maybe there should be a way for pure cmake packages to opt-in for a make run_tests call.

edit flag offensive delete link more

Comments

Thanks for your answer. Yeah, I looked into defining the target run_tests, but it got a bit messy. I agree with your last statement, that would be a helpful option.

Alexander Winkler gravatar imageAlexander Winkler ( 2018-07-10 10:49:09 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-07-07 10:33:16 -0600

Seen: 283 times

Last updated: Jul 27 '18