Why doesn't catkin run_tests re-generate modified message dependencies?

asked 2021-01-21 20:06:20 -0500

Rufus gravatar image

updated 2021-01-21 20:19:38 -0500

According to catkin --list-aliases

b: build
bt: b --this
install: config --install
ls: list
p: create pkg
run_tests: build --verbose --catkin-make-args run_tests --
test: build --verbose --make-args test --

If my understanding is correct, run_tests is just build with the additional invocation to run unit tests.

Suppose package A depends on some messages from package B. When I change the messages in package B and make the relevant changes in package A to accommodate the modified message, running catkin run_tests package_A gives me a compilation error as though it was using package B's old message format. I need to run catkin build package_A first before catkin run_tests package_A succeeds. Why is that the case?

I notice that using catkin run_tests package_A, I don't see the Generating C++ code from package_B/my_msg.msg as I do when running catkin build --verbose -- package_A.

CMakeLists.txt for package A is as follows

find_package(catkin REQUIRED COMPONENTS
    package_b
)

...

## Declare a C++ library
add_library(${PROJECT_NAME}
  src/package_a.cpp
)

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
)

...

catkin_add_gmock(${PROJECT_NAME}-test src/test_package_a.cpp)
if(TARGET ${PROJECT_NAME}-test)
  target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME} ${catkin_LIBRARIES})
endif()
edit retag flag offensive close merge delete