build: tests off by default, nav_test_harness only for tests
BUILD_MOVE_BASE2_TESTS now defaults to OFF in both build modes. nav_test_harness is a test-only package that exists only on the development machine. It was a catkin component and a build/run dependency, so configuring move_base2 failed on any machine without it, even with the tests off. It is now found inside the test block only and declared as test_depend. The scenario directory comes from the harness package config instead of a guessed ../nav_test_harness path, and the stale standalone include path is gone.
This commit is contained in:
@@ -90,7 +90,6 @@ if(NOT BUILDING_WITH_CATKIN)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../action_core/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../mission_adapters/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../robot_sensor_ports/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../nav_test_harness/include
|
||||
|
||||
/usr/local/include
|
||||
)
|
||||
@@ -168,8 +167,8 @@ else()
|
||||
# (MissionAdapterBridge dịch contract, MissionLayer lắp ráp framework).
|
||||
mission_adapters
|
||||
|
||||
# scenario_test chạy kịch bản khai báo qua khung của nav_test_harness.
|
||||
nav_test_harness
|
||||
# nav_test_harness KHÔNG nằm ở đây: gói chỉ có trên máy dev, chỉ test dùng. Nó được
|
||||
# find_package riêng trong khối test, để máy không có gói này vẫn build được move_base2.
|
||||
)
|
||||
|
||||
find_library(TF3_LIBRARY
|
||||
@@ -415,14 +414,29 @@ endif()
|
||||
# ========================================================
|
||||
# Tests
|
||||
# ========================================================
|
||||
option(BUILD_MOVE_BASE2_TESTS "Build move_base2 tests" ON)
|
||||
# Tests are OFF by default in both build modes; enable with -DBUILD_MOVE_BASE2_TESTS=ON.
|
||||
option(BUILD_MOVE_BASE2_TESTS "Build move_base2 tests" OFF)
|
||||
|
||||
if(BUILD_MOVE_BASE2_TESTS AND BUILDING_WITH_CATKIN)
|
||||
if(BUILD_MOVE_BASE2_TESTS AND BUILDING_WITH_CATKIN AND CATKIN_ENABLE_TESTING)
|
||||
|
||||
if(NOT COMMAND catkin_add_gtest)
|
||||
message(FATAL_ERROR "catkin_add_gtest NOT FOUND")
|
||||
endif()
|
||||
|
||||
# Bộ fake và scenario runner dùng chung cho test. Chỉ tìm khi bật test: gói này chỉ có trên máy dev.
|
||||
find_package(nav_test_harness REQUIRED)
|
||||
|
||||
# Kịch bản là DỮ LIỆU nằm ở nav_test_harness; test không được đoán đường dẫn tới nó.
|
||||
# devel space: thư mục nguồn của gói; install space: share/nav_test_harness/scenarios.
|
||||
if(nav_test_harness_SOURCE_PREFIX)
|
||||
set(MOVE_BASE2_SCENARIO_DIR "${nav_test_harness_SOURCE_PREFIX}/scenarios")
|
||||
else()
|
||||
get_filename_component(MOVE_BASE2_SCENARIO_DIR "${nav_test_harness_DIR}/../scenarios" ABSOLUTE)
|
||||
endif()
|
||||
if(NOT EXISTS "${MOVE_BASE2_SCENARIO_DIR}")
|
||||
message(FATAL_ERROR "move_base2: nav_test_harness scenarios not found at '${MOVE_BASE2_SCENARIO_DIR}'")
|
||||
endif()
|
||||
|
||||
# Plugin global planner chỉ dùng cho test — nạp qua Boost.DLL đúng đường runtime đi, không link
|
||||
# thẳng. Đặt trong nhánh test để không bao giờ lọt vào bản cài đặt.
|
||||
foreach(test_plugin move_base2_test_global_planner move_base2_test_local_planner)
|
||||
@@ -494,12 +508,14 @@ if(BUILD_MOVE_BASE2_TESTS AND BUILDING_WITH_CATKIN)
|
||||
target_include_directories(${test_name} SYSTEM
|
||||
PRIVATE
|
||||
${catkin_INCLUDE_DIRS}
|
||||
${nav_test_harness_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# catkin_add_gtest đã dùng target_link_libraries dạng plain, nên phần bổ sung cũng phải plain.
|
||||
target_link_libraries(${test_name}
|
||||
move_base2_core
|
||||
${catkin_LIBRARIES}
|
||||
${nav_test_harness_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
yaml-cpp
|
||||
${CMAKE_DL_LIBS}
|
||||
@@ -510,8 +526,7 @@ if(BUILD_MOVE_BASE2_TESTS AND BUILDING_WITH_CATKIN)
|
||||
target_compile_definitions(${test_name} PRIVATE
|
||||
MOVE_BASE2_TEST_CONFIG_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test/config"
|
||||
MOVE_BASE2_TEST_LIBRARY_DIR="${CATKIN_DEVEL_PREFIX}/lib"
|
||||
# Kịch bản là DỮ LIỆU nằm ở nav_test_harness; test không được đoán đường dẫn tới nó.
|
||||
MOVE_BASE2_SCENARIO_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../nav_test_harness/scenarios"
|
||||
MOVE_BASE2_SCENARIO_DIR="${MOVE_BASE2_SCENARIO_DIR}"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -69,9 +69,9 @@
|
||||
<build_depend>yaml-cpp</build_depend>
|
||||
<run_depend>yaml-cpp</run_depend>
|
||||
|
||||
<!-- Chỉ dùng cho test: bộ fake và scenario runner dùng chung. -->
|
||||
<build_depend>nav_test_harness</build_depend>
|
||||
<run_depend>nav_test_harness</run_depend>
|
||||
<!-- Chỉ dùng cho test: bộ fake và scenario runner dùng chung. Gói chỉ có trên máy dev, nên chỉ
|
||||
là test_depend; CMake chỉ find_package nó khi bật BUILD_MOVE_BASE2_TESTS. -->
|
||||
<test_depend>nav_test_harness</test_depend>
|
||||
|
||||
<build_depend>recovery_core</build_depend>
|
||||
<run_depend>recovery_core</run_depend>
|
||||
|
||||
Reference in New Issue
Block a user