Skip to content

Commit

Permalink
fix aws_common tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yt committed Aug 31, 2023
1 parent e60cd01 commit eafc9e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions utils-common/aws_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
### Tests ###
#############
enable_testing()
find_package(GTest QUIET)
include(${CMAKE_SOURCE_DIR}/cmake/DefineTestMacros.cmake)
find_common_test_packages()
add_common_gtest(test_aws_log_system test/sdk_utils/logging/aws_log_system_test.cpp)
Expand All @@ -71,6 +72,7 @@ add_common_gtest(test_client_configuration_provider test/sdk_utils/client_config
add_common_gtest(test_service_credentials_provider test/sdk_utils/auth/service_credentials_provider_test.cpp)
add_common_gtest(test_wordexp_ros test/fs_utils/wordexp_ros_test.cpp)


add_library(test_utils test/sdk_utils/parameter_reader_mock.cpp)
target_include_directories(test_utils PUBLIC ${PROJECT_SOURCE_DIR}/test/include)

Expand All @@ -87,10 +89,15 @@ set(HEADERS_FOR_TESTS
${AWSSDK_INCLUDE_DIR}
)


macro(link_test_target target_name)
if(TARGET ${target_name})
target_include_directories("${target_name}" PRIVATE ${HEADERS_FOR_TESTS})
target_link_libraries("${target_name}" ${LIBS_FOR_TESTS})
target_include_directories("${target_name}" PRIVATE ${HEADERS_FOR_TESTS} ${aws_common_INCLUDE_DIRS} ${AWSSDK_INCLUDE_DIR})
target_link_libraries("${target_name}" ${LIBS_FOR_TESTS} ${GTEST_LIBRARIES}
pthread
${aws_common_LIBRARIES}
${PROJECT_NAME})
add_test(NAME ${target_name} COMMAND ${target_name} --gtest_output=xml:test_results/)
endif()
endmacro()

Expand Down Expand Up @@ -130,4 +137,4 @@ INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/external/${CMAKE_INSTALL_LIBDIR}/cmake/A
INSTALL(FILES ${CMAKE_SOURCE_DIR}/cmake/DefineTestMacros.cmake DESTINATION share/${PROJECT_NAME}/cmake)
INSTALL(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION share/${PROJECT_NAME}/cmake)
INSTALL(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION share/${PROJECT_NAME}/cmake)
INSTALL(EXPORT ${PROJECT_NAME}-targets DESTINATION share/${PROJECT_NAME}/cmake)
INSTALL(EXPORT ${PROJECT_NAME}-targets DESTINATION share/${PROJECT_NAME}/cmake)
2 changes: 1 addition & 1 deletion utils-common/aws_common/cmake/DefineTestMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ macro(add_common_gtest target)
if(catkin_FOUND)
message(STATUS "Building tests using catkin")
set(GTEST_LIBRARIES "") # hack so that linking against libgmock doesn't also link against libgtest
catkin_add_gmock("${target}" ${ARGN})
add_executable("${target}" ${ARGN})
elseif(ament_cmake_gtest_FOUND)
message(STATUS "Building tests using ament")
ament_add_gmock("${target}" ${ARGN})
Expand Down

0 comments on commit eafc9e2

Please sign in to comment.