Skip to content

Commit

Permalink
guard for windows (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
stonier authored Jun 29, 2019
1 parent b7e9ad5 commit 7005db3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
7 changes: 7 additions & 0 deletions launch/launch/actions/execute_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,13 @@ async def __execute_process(self, context: LaunchContext) -> None:
))
except KeyError:
emulate_tty = self.__emulate_tty
# guard against windows - tty emulation is not yet working
# https://github.com/ros2/launch/issues/268
if emulate_tty and platform.system() == 'Windows':
self.__logger.warning(
"tty emulation not yet supported on windows, disabling"
)
emulate_tty = False
try:
transport, self._subprocess_protocol = await async_execute_process(
lambda **kwargs: self.__ProcessProtocol(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"""Tests for emulate_tty configuration of ExecuteProcess actions."""

import platform
import sys

import launch
Expand All @@ -29,19 +30,35 @@ def handle(self, event, context):
self.returncode = event.returncode


def tty_expected_unless_windows():
return 1 if platform.system() != 'Windows' else 0


@pytest.mark.parametrize('test_input,expected', [
(None, 1), # use the default defined by ExecuteProcess
('true', 1), # redundantly override the default via LaunchConfiguration
('false', 0) # override the default via LaunchConfiguration
# use the default defined by ExecuteProcess
(None, tty_expected_unless_windows()),
# redundantly override the default via LaunchConfiguration
('true', tty_expected_unless_windows()),
# override the default via LaunchConfiguration
('false', 0)
])
def test_emulate_tty(test_input, expected):
on_exit = OnExit()
ld = launch.LaunchDescription()
ld.add_action(launch.actions.ExecuteProcess(
cmd=[sys.executable, '-c', 'import sys; sys.exit(sys.stdout.isatty())'])
cmd=[sys.executable,
'-c',
'import sys; sys.exit(sys.stdout.isatty())'
]
)
)
if test_input is not None:
ld.add_action(launch.actions.SetLaunchConfiguration('emulate_tty', test_input))
ld.add_action(
launch.actions.SetLaunchConfiguration(
'emulate_tty',
test_input
)
)
ld.add_action(
launch.actions.RegisterEventHandler(
launch.event_handlers.OnProcessExit(on_exit=on_exit.handle)
Expand Down

0 comments on commit 7005db3

Please sign in to comment.