Skip to content
Open
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
6 changes: 4 additions & 2 deletions launch/launch/actions/execute_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,14 @@ def parse(
kwargs['sigterm_timeout'] = str(sigterm_timeout)

if 'shell' not in ignore:
shell = entity.get_attr('shell', data_type=bool, optional=True)
shell = entity.get_attr(
'shell', data_type=bool, optional=True, can_be_str=False)
if shell is not None:
kwargs['shell'] = shell

if 'emulate_tty' not in ignore:
emulate_tty = entity.get_attr('emulate_tty', data_type=bool, optional=True)
emulate_tty = entity.get_attr(
'emulate_tty', data_type=bool, optional=True, can_be_str=False)
if emulate_tty is not None:
kwargs['emulate_tty'] = emulate_tty

Expand Down
9 changes: 9 additions & 0 deletions launch_xml/test/launch_xml/test_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,14 @@ def test_executable_on_exit():
assert isinstance(sub_entities[0], Shutdown)


@pytest.mark.parametrize('attribute', ('shell', 'emulate_tty'))
def test_executable_rejects_invalid_boolean_attributes(attribute):
xml_file = f'<launch><executable cmd="echo" {attribute}="invalid"/></launch>'
root_entity, parser = load_no_extensions(io.StringIO(xml_file))

with pytest.raises(TypeError, match=f"Attribute '{attribute}'"):
parser.parse_description(root_entity)


if __name__ == '__main__':
test_executable()
17 changes: 17 additions & 0 deletions launch_yaml/test/launch_yaml/test_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

from parser_no_extensions import load_no_extensions

import pytest


def test_executable():
"""Parse executable yaml example."""
Expand Down Expand Up @@ -82,5 +84,20 @@ def test_executable_on_exit():
assert isinstance(sub_entities[0], Shutdown)


@pytest.mark.parametrize('attribute', ('shell', 'emulate_tty'))
def test_executable_rejects_invalid_boolean_attributes(attribute):
yaml_file = f"""\
launch:
- executable:
cmd: echo
{attribute}: invalid
"""
yaml_file = textwrap.dedent(yaml_file)
root_entity, parser = load_no_extensions(io.StringIO(yaml_file))

with pytest.raises(TypeError, match=f"Attribute '{attribute}'"):
parser.parse_description(root_entity)


if __name__ == '__main__':
test_executable()