diff --git a/rcl/package.xml b/rcl/package.xml index e9371d831..7cfaef6ba 100644 --- a/rcl/package.xml +++ b/rcl/package.xml @@ -34,7 +34,7 @@ ament_lint_common rmw rmw_implementation_cmake - launch + launch_testing osrf_testing_tools_cpp test_msgs diff --git a/rcl/test/rcl/test_rmw_impl_id_check.py.in b/rcl/test/rcl/test_rmw_impl_id_check.py.in index fa5ebed67..a3311d6e1 100644 --- a/rcl/test/rcl/test_rmw_impl_id_check.py.in +++ b/rcl/test/rcl/test_rmw_impl_id_check.py.in @@ -2,35 +2,40 @@ import os -from launch.legacy import LaunchDescriptor -from launch.legacy.launcher import DefaultLauncher +from launch import LaunchDescription +from launch import LaunchService +from launch.actions import ExecuteProcess +from launch_testing import LaunchTestService def launch_test( rmw_implementation_env=None, rcl_assert_rmw_id_matches_env=None, expect_failure=False ): - ld = LaunchDescriptor() + launch_test = LaunchTestService() + launch_description = LaunchDescription() env = dict(os.environ) if rmw_implementation_env is not None: - env['RMW_IMPLEMENTATION'] = rmw_implementation_env + env['RMW_IMPLEMENTATION'] = rmw_implementation_env if rcl_assert_rmw_id_matches_env is not None: - env['RCL_ASSERT_RMW_ID_MATCHES'] = rcl_assert_rmw_id_matches_env - - ld.add_process( - cmd=['@TEST_RMW_IMPL_ID_CHECK_EXECUTABLE_NAME@'], - name='@TEST_RMW_IMPL_ID_CHECK_EXECUTABLE_NAME@', - env=env, + env['RCL_ASSERT_RMW_ID_MATCHES'] = rcl_assert_rmw_id_matches_env + + launch_test.add_test_action( + launch_description, ExecuteProcess( + cmd=['@TEST_RMW_IMPL_ID_CHECK_EXECUTABLE_NAME@'], + name='@TEST_RMW_IMPL_ID_CHECK_EXECUTABLE_NAME@', + env=env, + ) ) - launcher = DefaultLauncher() - launcher.add_launch_descriptor(ld) - rc = launcher.launch() + launch_service = LaunchService() + launch_service.include_launch_description(launch_description) + rc = launch_test.run(launch_service) if expect_failure: - assert rc != 0, 'The executable did not fail as expected.' + assert rc != 0, 'The executable did not fail as expected.' else: - assert rc == 0, "The executable failed with exit code '" + str(rc) + "'. " + assert rc == 0, "The executable failed with exit code '" + str(rc) + "'. " def test_rmw_implementation_env(): @@ -71,6 +76,6 @@ def test_both(): if __name__ == '__main__': - test_rmw_impl_env() + test_rmw_implementation_env() test_rcl_assert_rmw_id_matches_env() test_both() diff --git a/rcl/test/rcl/test_two_executables.py.in b/rcl/test/rcl/test_two_executables.py.in index 71748464b..bffaa709e 100644 --- a/rcl/test/rcl/test_two_executables.py.in +++ b/rcl/test/rcl/test_two_executables.py.in @@ -1,29 +1,32 @@ # generated from rcl/test/test_two_executables.py.in -from launch.legacy import LaunchDescriptor -from launch.legacy.exit_handler import ignore_signal_exit_handler -from launch.legacy.exit_handler import primary_exit_handler -from launch.legacy.launcher import DefaultLauncher +from launch import LaunchDescription +from launch import LaunchService +from launch.actions import ExecuteProcess +from launch_testing import LaunchTestService def @TEST_NAME@(): - ld = LaunchDescriptor() - - ld.add_process( - cmd=['@TEST_EXECUTABLE1@'], - name='@TEST_EXECUTABLE1_NAME@', - exit_handler=ignore_signal_exit_handler, + launch_test = LaunchTestService() + launch_description = LaunchDescription() + + launch_test.add_fixture_action( + launch_description, ExecuteProcess( + cmd=['@TEST_EXECUTABLE1@'], + name='@TEST_EXECUTABLE1_NAME@', + ), exit_allowed=True ) - ld.add_process( - cmd=['@TEST_EXECUTABLE2@', '@TEST_EXECUTABLE1_NAME@'], - name='@TEST_EXECUTABLE2_NAME@', - exit_handler=primary_exit_handler, + launch_test.add_test_action( + launch_description, ExecuteProcess( + cmd=['@TEST_EXECUTABLE2@', '@TEST_EXECUTABLE1_NAME@'], + name='@TEST_EXECUTABLE2_NAME@', + ) ) - launcher = DefaultLauncher() - launcher.add_launch_descriptor(ld) - rc = launcher.launch() + launch_service = LaunchService() + launch_service.include_launch_description(launch_description) + rc = launch_test.run(launch_service) assert rc == 0, "The launch file failed with exit code '" + str(rc) + "'. "