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

Drops legacy launch API usage. #387

Merged
merged 2 commits into from
Feb 27, 2019
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
2 changes: 1 addition & 1 deletion rcl/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<test_depend>ament_lint_common</test_depend>
<test_depend>rmw</test_depend>
<test_depend>rmw_implementation_cmake</test_depend>
<test_depend>launch</test_depend>
<test_depend>launch_testing</test_depend>
Copy link
Member

Choose a reason for hiding this comment

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

Just a note: this adds another case of a circular repository dependency (same as for the test dependency on launch).

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't make that case any worse, but it is just an actual circular dependency. The testing code will likely need to be split into ROS and non-ROS parts like launch itself is, otherwise anything at or below rclcpp/rclpy will not be able to use any of it.

<test_depend>osrf_testing_tools_cpp</test_depend>
<test_depend>test_msgs</test_depend>

Expand Down
37 changes: 21 additions & 16 deletions rcl/test/rcl/test_rmw_impl_id_check.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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()
37 changes: 20 additions & 17 deletions rcl/test/rcl/test_two_executables.py.in
Original file line number Diff line number Diff line change
@@ -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) + "'. "

Expand Down