From f3d69c85409fdcfee714a140de63321896da1d5f Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 22 Jul 2024 15:54:35 +0000 Subject: [PATCH] Remove separate test launch file --- controller_manager/CMakeLists.txt | 2 +- controller_manager/test/cm.launch.py | 45 ------------------- .../test/test_ros2_control_node_launch.py | 29 +++++++----- 3 files changed, 18 insertions(+), 58 deletions(-) delete mode 100644 controller_manager/test/cm.launch.py diff --git a/controller_manager/CMakeLists.txt b/controller_manager/CMakeLists.txt index 3f54baf732..c4ef0e7df0 100644 --- a/controller_manager/CMakeLists.txt +++ b/controller_manager/CMakeLists.txt @@ -211,7 +211,7 @@ if(BUILD_TESTING) ) find_package(ament_cmake_pytest REQUIRED) - install(FILES test/test_ros2_control_node.yaml test/cm.launch.py + install(FILES test/test_ros2_control_node.yaml DESTINATION test) ament_add_pytest_test(test_ros2_control_node test/test_ros2_control_node_launch.py) endif() diff --git a/controller_manager/test/cm.launch.py b/controller_manager/test/cm.launch.py deleted file mode 100644 index 24364a859f..0000000000 --- a/controller_manager/test/cm.launch.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2024 AIT - Austrian Institute of Technology GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from launch import LaunchDescription -from launch.substitutions import PathJoinSubstitution - -from launch_ros.actions import Node -from launch_ros.substitutions import FindPackageShare - - -def generate_launch_description(): - # Declare arguments - declared_arguments = [] - - robot_controllers = PathJoinSubstitution( - [ - FindPackageShare("controller_manager"), - "test", - "test_ros2_control_node.yaml", - ] - ) - - control_node = Node( - package="controller_manager", - executable="ros2_control_node", - parameters=[robot_controllers], - output="both", - ) - nodes = [ - control_node, - ] - - return LaunchDescription(declared_arguments + nodes) diff --git a/controller_manager/test/test_ros2_control_node_launch.py b/controller_manager/test/test_ros2_control_node_launch.py index 1795f4a0cd..c8c1136849 100644 --- a/controller_manager/test/test_ros2_control_node_launch.py +++ b/controller_manager/test/test_ros2_control_node_launch.py @@ -28,19 +28,18 @@ # # Author: Christoph Froehlich -import os import pytest import unittest import time -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription -from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest import launch_testing.markers import rclpy +import launch_ros.actions from rclpy.node import Node @@ -48,16 +47,22 @@ @pytest.mark.launch_test def generate_test_description(): - launch_include = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - os.path.join( - get_package_share_directory("controller_manager"), - "../../test/cm.launch.py", - ) - ), + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare("controller_manager"), + "test", + "test_ros2_control_node.yaml", + ] ) - return LaunchDescription([launch_include, ReadyToTest()]) + control_node = launch_ros.actions.Node( + package="controller_manager", + executable="ros2_control_node", + parameters=[robot_controllers], + output="both", + ) + + return LaunchDescription([control_node, ReadyToTest()]) # This is our test fixture. Each method is a test case.