From 5f6b95f454b8e0c28a3259d752b239e0eaf30651 Mon Sep 17 00:00:00 2001
From: Olivier Stasse <ostasse@laas.fr>
Date: Tue, 18 Apr 2023 11:43:52 +0200
Subject: [PATCH] [tests] Fix the way the test library is build and the Path in
 launch files.

---
 tests/CMakeLists.txt                           |  8 ++------
 tests/launch/launching_test_sot_loader.py      | 11 +++++------
 .../launch/launching_test_sot_loader_basic.py  | 18 ++++++++++--------
 3 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7ffb1d8..ecf044c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -14,7 +14,6 @@ if(BUILD_TESTING)
   add_library(impl_test_sot_mock_device SHARED impl_test_sot_mock_device.cpp)
   set_target_properties(impl_test_sot_mock_device PROPERTIES INSTALL_RPATH
                                                              $ORIGIN)
-  # target_include_directories(impl_test_sot_mock_device PUBLIC include)
   target_link_libraries(
     impl_test_sot_mock_device PUBLIC sot-core::sot-core
                                      dynamic-graph-python::dynamic-graph-python)
@@ -32,15 +31,12 @@ if(BUILD_TESTING)
     dynamic_graph_bridge-impl_test_sot_mock_device-wrap SOURCE_PYTHON_MODULE
     "${CMAKE_CURRENT_SOURCE_DIR}/impl_test_sot_mock_device-python-module-py.cc")
 
-  install(
-    TARGETS ${plugin_library_name}
-    EXPORT ${TARGETS_EXPORT_NAME}
-    DESTINATION ${DYNAMIC_GRAPH_PLUGINDIR})
   # Library for sot_external_interface
   add_library(impl_test_library SHARED impl_test_sot_external_interface.cpp)
 
   target_include_directories(impl_test_library PUBLIC include)
-  target_link_libraries(impl_test_library PUBLIC sot-core::sot-core)
+  target_link_libraries(impl_test_library PUBLIC impl_test_sot_mock_device
+                                                 sot-core::sot-core)
   ament_target_dependencies(impl_test_library PUBLIC dynamic_graph_bridge_msgs
                             rclcpp rcl_interfaces std_srvs)
   # Executable for SotLoaderBasic test
diff --git a/tests/launch/launching_test_sot_loader.py b/tests/launch/launching_test_sot_loader.py
index cb713bc..2080ad0 100644
--- a/tests/launch/launching_test_sot_loader.py
+++ b/tests/launch/launching_test_sot_loader.py
@@ -31,7 +31,7 @@ from launch_ros.actions import Node
 def generate_test_description():
     """Load a simple urdf, parameters and the library."""
     ld = LaunchDescription()
-
+    print("After launch description")
     robot_description_content_path = PathJoinSubstitution(
         [
             get_package_share_directory("dynamic_graph_bridge"),
@@ -39,11 +39,10 @@ def generate_test_description():
             "dgb_minimal_robot.urdf",
         ],
     )
-
-    robot_description_content = Path.open(
-        robot_description_content_path.perform(None),
-    ).read()
-
+    print("Before robot_description_content")
+    robot_description_content_path = Path(robot_description_content_path.perform(None))
+    robot_description_content = robot_description_content_path.open().read()
+    print("Before params")
     params = {
         "state_vector_map": ["joint1", "joint2"],
         "robot_description": robot_description_content,
diff --git a/tests/launch/launching_test_sot_loader_basic.py b/tests/launch/launching_test_sot_loader_basic.py
index 5a6eba4..13b5ad1 100644
--- a/tests/launch/launching_test_sot_loader_basic.py
+++ b/tests/launch/launching_test_sot_loader_basic.py
@@ -33,17 +33,19 @@ def generate_test_description():
 
     It also set parameters state_vector_map and robot_description
     """
+    print("start generate_test_description")
     ld = LaunchDescription()
 
-    robot_description_content_path = (
-        Path(get_package_share_directory("dynamic_graph_bridge"))
-        / "urdf"
-        / "dgb_minimal_robot.urdf"
+    robot_description_pathjs_str = PathJoinSubstitution(
+        [
+            get_package_share_directory("dynamic_graph_bridge"),
+            "urdf",
+            "dgb_minimal_robot.urdf",
+        ],
     )
-    assert robot_description_content_path.exists()
-    robot_description_content = Path.open(
-        PathJoinSubstitution(str(robot_description_content_path)).perform(None),
-    ).read()
+    robot_description_path = Path(robot_description_pathjs_str.perform(None))
+    robot_description_content = robot_description_path.open().read()
+    print("After building robot_description_content")
     terminating_process = Node(
         package="dynamic_graph_bridge",
         executable="test_sot_loader_basic",
-- 
GitLab