-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to build and run unit tests with catkin
- Loading branch information
1 parent
c59d214
commit 3a81838
Showing
4 changed files
with
50 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
|
||
if(ENABLE_UNIT_TESTS) | ||
|
||
# Gimbal controller plugin | ||
add_executable(gazebo_gimbal_controller_plugin_test gazebo_gimbal_controller_plugin_test.cpp) | ||
if(ENABLE_UNIT_TESTS OR CATKIN_ENABLE_TESTING) | ||
|
||
target_link_libraries(gazebo_gimbal_controller_plugin_test | ||
PRIVATE gazebo_gimbal_controller_plugin | ||
${GTEST_BOTH_LIBRARIES} | ||
${CMAKE_THREAD_LIBS_INIT}) | ||
# Uniform way to add unit tests. This works with catkin and with plain CMake. | ||
function(add_unit_test target) # add sources as ARGN | ||
|
||
add_test(gazebo_gimbal_controller_plugin_test gazebo_gimbal_controller_plugin_test) | ||
if(ENABLE_UNIT_TESTS) | ||
|
||
# GPS plugin | ||
add_executable(gazebo_gps_plugin_test gazebo_gps_plugin_test.cpp) | ||
# Plain CMake to add google test | ||
add_executable(${target} ${ARGN}) | ||
add_test(${target} ${target}) | ||
|
||
elseif(CATKIN_ENABLE_TESTING) | ||
|
||
# Catkin google test facilities | ||
catkin_add_gtest(${target} ${ARGN}) | ||
|
||
endif(ENABLE_UNIT_TESTS) | ||
|
||
# Link the gtest libraries in any case | ||
target_link_libraries(${target} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) | ||
|
||
endfunction(add_unit_test) | ||
|
||
target_link_libraries(gazebo_gps_plugin_test | ||
PRIVATE gazebo_gps_plugin | ||
${GTEST_BOTH_LIBRARIES} | ||
${CMAKE_THREAD_LIBS_INIT}) | ||
|
||
add_test(gazebo_gps_plugin_test gazebo_gps_plugin_test) | ||
# Add the tests | ||
|
||
|
||
# Gimbal controller plugin | ||
add_unit_test(gazebo_gimbal_controller_plugin_test gazebo_gimbal_controller_plugin_test.cpp) | ||
target_link_libraries(gazebo_gimbal_controller_plugin_test gazebo_gimbal_controller_plugin) | ||
|
||
# GPS plugin | ||
add_unit_test(gazebo_gps_plugin_test gazebo_gps_plugin_test.cpp) | ||
target_link_libraries(gazebo_gps_plugin_test gazebo_gps_plugin) | ||
|
||
|
||
endif(ENABLE_UNIT_TESTS) | ||
endif(ENABLE_UNIT_TESTS OR CATKIN_ENABLE_TESTING) |