Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to use new memory_tools from osrf_testing_tools_cpp #101

Merged
merged 7 commits into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 33 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,21 @@ configure_file(
set(rcutils_module_path ${CMAKE_CURRENT_SOURCE_DIR})
set(python_code
"import em"
"em.invoke(['-o', 'include/rcutils/logging_macros.h', '-D', 'rcutils_module_path=\"${rcutils_module_path}\"', '${CMAKE_CURRENT_SOURCE_DIR}/resource/logging_macros.h.em'])")
"\
em.invoke( \
[ \
'-o', 'include/rcutils/logging_macros.h', \
'-D', 'rcutils_module_path=\"${rcutils_module_path}\"', \
'${CMAKE_CURRENT_SOURCE_DIR}/resource/logging_macros.h.em' \
] \
)")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhood I broke this line up because it was pretty long. It appears to work correctly, but if you'd prefer it not to be this way I can revert it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine by me thanks

string(REPLACE ";" "$<SEMICOLON>" python_code "${python_code}")
add_custom_command(OUTPUT include/rcutils/logging_macros.h
COMMAND ${CMAKE_COMMAND} -E make_directory "include/rcutils"
COMMAND ${PYTHON_EXECUTABLE} ARGS -c "${python_code}"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/logging_macros.h.em.watch" "${CMAKE_CURRENT_BINARY_DIR}/logging.py.watch"
DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/logging_macros.h.em.watch"
"${CMAKE_CURRENT_BINARY_DIR}/logging.py.watch"
COMMENT "Expanding logging_macros.h.em"
VERBATIM
)
Expand Down Expand Up @@ -108,48 +117,44 @@ if(BUILD_TESTING)
if(ament_cmake_cppcheck_FOUND)
ament_cppcheck(
TESTNAME "cppcheck_logging_macros"
"${CMAKE_CURRENT_BINARY_DIR}/include/rcutils/logging_macros.h")
"${CMAKE_CURRENT_BINARY_DIR}/include/rcutils/logging_macros.h")
endif()
if(ament_cmake_cpplint_FOUND)
ament_cpplint(
TESTNAME "cpplint_logging_macros"
# the generated code might contain longer lines for templated types
MAX_LINE_LENGTH 999
ROOT "${CMAKE_CURRENT_BINARY_DIR}/include"
"${CMAKE_CURRENT_BINARY_DIR}/include/rcutils/logging_macros.h")
"${CMAKE_CURRENT_BINARY_DIR}/include/rcutils/logging_macros.h")
endif()
if(ament_cmake_uncrustify_FOUND)
ament_uncrustify(
TESTNAME "uncrustify_logging_macros"
# the generated code might contain longer lines for templated types
MAX_LINE_LENGTH 999
"${CMAKE_CURRENT_BINARY_DIR}/include/rcutils/logging_macros.h")
"${CMAKE_CURRENT_BINARY_DIR}/include/rcutils/logging_macros.h")
endif()

set(extra_test_libraries)
set(extra_test_env)
set(extra_lib_dirs)
find_package(osrf_testing_tools_cpp REQUIRED)
get_target_property(memory_tools_test_env_vars
osrf_testing_tools_cpp::memory_tools LIBRARY_PRELOAD_ENVIRONMENT_VARIABLE)

ament_add_gtest(test_logging test/test_logging.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs})
ament_add_gtest(test_logging test/test_logging.cpp)
target_link_libraries(test_logging ${PROJECT_NAME})

add_executable(test_logging_long_messages test/test_logging_long_messages.cpp)
target_link_libraries(test_logging_long_messages ${PROJECT_NAME})
ament_add_pytest_test(test_logging_long_messages
"test/test_logging_long_messages.py"
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
WORKING_DIRECTORY "$<TARGET_FILE_DIR:test_logging_long_messages>"
TIMEOUT 10)

ament_add_pytest_test(test_logging_output_format
"test/test_logging_output_format.py"
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
WORKING_DIRECTORY "$<TARGET_FILE_DIR:test_logging_long_messages>"
TIMEOUT 10)

ament_add_gmock(test_logging_macros test/test_logging_macros.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs})
ament_add_gmock(test_logging_macros test/test_logging_macros.cpp)
target_link_libraries(test_logging_macros ${PROJECT_NAME})

add_executable(test_logging_macros_c test/test_logging_macros.c)
Expand All @@ -158,12 +163,15 @@ if(BUILD_TESTING)
COMMAND "$<TARGET_FILE:test_logging_macros_c>"
GENERATE_RESULT_FOR_RETURN_CODE_ZERO)

# This subdirectory extends both extra_test_libraries, extra_test_env, and extra_lib_dirs.
add_subdirectory(test/memory_tools)

set(SKIP_TEST_IF_WIN32 "")
if(WIN32) # (memory tools doesn't do anything on Windows)
set(SKIP_TEST_IF_WIN32 "SKIP_TEST")
set(SKIP_TEST_IF_WIN32_OR_AARCH64 "")
if(WIN32)
# (memory tools doesn't do anything on Windows)
set(SKIP_TEST_IF_WIN32_OR_AARCH64 "SKIP_TEST")
endif()
# TODO(wjwwood): reenable for ARM (aarch64) when fixed in osrf_testing_tools_cpp
# see: https://github.com/osrf/osrf_testing_tools_cpp/issues/3
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(SKIP_TEST_IF_WIN32_OR_AARCH64 "SKIP_TEST")
endif()

macro(rcutils_custom_add_gtest target)
Expand All @@ -176,12 +184,11 @@ if(BUILD_TESTING)

# Gtests
rcutils_custom_add_gtest(test_allocator test/test_allocator.cpp
ENV ${extra_test_env}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
${SKIP_TEST_IF_WIN32}
ENV ${memory_tools_test_env_vars}
${SKIP_TEST_IF_WIN32_OR_AARCH64}
)
if(TARGET test_allocator)
target_link_libraries(test_allocator ${PROJECT_NAME} ${extra_test_libraries})
target_link_libraries(test_allocator ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools)
endif()

rcutils_custom_add_gmock(test_error_handling test/test_error_handling.cpp
Expand Down Expand Up @@ -274,10 +281,9 @@ if(BUILD_TESTING)

rcutils_custom_add_gtest(test_time
test/test_time.cpp
ENV ${extra_test_env}
APPEND_LIBRARY_DIRS ${extra_lib_dirs})
ENV ${memory_tools_test_env_vars})
if(TARGET test_time)
target_link_libraries(test_time ${PROJECT_NAME} ${extra_test_libraries})
target_link_libraries(test_time ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools)
endif()
endif()

Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>launch_testing</test_depend>
<test_depend>osrf_testing_tools_cpp</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
43 changes: 0 additions & 43 deletions test/memory_tools/CMakeLists.txt

This file was deleted.

143 changes: 0 additions & 143 deletions test/memory_tools/memory_tools.cpp

This file was deleted.

Loading