diff --git a/ros2doctor/test/test_report.py b/ros2doctor/test/test_report.py index b3e7052db..0ff79b3b3 100644 --- a/ros2doctor/test/test_report.py +++ b/ros2doctor/test/test_report.py @@ -24,6 +24,10 @@ from launch import LaunchDescription from launch import LaunchService from launch.actions import ExecuteProcess +from launch.actions import RegisterEventHandler +from launch.actions import ResetEnvironment +from launch.actions import SetEnvironmentVariable +from launch.event_handlers import OnShutdown from launch_ros.actions import Node @@ -32,6 +36,7 @@ import launch_testing.asserts import launch_testing.markers import launch_testing.tools +from launch_testing_ros.actions import EnableRmwIsolation import launch_testing_ros.tools import pytest @@ -55,21 +60,23 @@ def generate_test_description(rmw_implementation: str) -> Tuple[LaunchDescriptio path_to_fixtures = os.path.join(os.path.dirname(__file__), 'fixtures') additional_env = get_rmw_additional_env(rmw_implementation) additional_env['PYTHONUNBUFFERED'] = '1' + set_env_actions = [SetEnvironmentVariable(k, v) for k, v in additional_env.items()] return LaunchDescription([ ExecuteProcess( cmd=['ros2', 'daemon', 'stop'], name='daemon-stop', on_exit=[ + RegisterEventHandler(OnShutdown(on_shutdown=ResetEnvironment())), + *set_env_actions, + EnableRmwIsolation(), ExecuteProcess( cmd=['ros2', 'daemon', 'start'], name='daemon-start', - additional_env=additional_env, on_exit=[ Node( executable=sys.executable, arguments=[os.path.join(path_to_fixtures, 'report_node.py')], - additional_env=additional_env ), launch_testing.actions.ReadyToTest() ] @@ -100,11 +107,8 @@ def launch_doctor_command( self, arguments ) -> Generator[launch_testing.tools.process.ProcessProxy, None, None]: - additional_env = get_rmw_additional_env(rmw_implementation) - additional_env['PYTHONUNBUFFERED'] = '1' doctor_command_action = ExecuteProcess( cmd=['ros2', 'doctor', *arguments], - additional_env=additional_env, name='ros2doctor-cli', output='screen' ) @@ -130,11 +134,6 @@ def test_check(self) -> None: @launch_testing.markers.retry_on_failure(times=5, delay=1) def test_report(self) -> None: - # TODO(@fujitatomoya): rmw_zenoh_cpp is instable to find the endpoints, it does not - # matter if DaemonNode or DirectNode is used. For now, skip the test for rmw_zenoh_cpp. - if self.rmw_implementation == 'rmw_zenoh_cpp': - raise unittest.SkipTest() - for argument in ['-r', '--report']: with self.launch_doctor_command( arguments=[argument]