Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
Distro A; OPSEC #4584

Signed-off-by: Roger Strain <rstrain@swri.org>
  • Loading branch information
Roger Strain committed Mar 10, 2021
1 parent 7f21a4f commit dc7f80b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion launch/launch/descriptions/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def __init__(
:param: arguments list of extra arguments for the executable
"""
self.__cmd = [normalize_to_list_of_substitutions(x) for x in cmd]
self.__cmd += [] if arguments is None else [normalize_to_list_of_substitutions(x) for x in arguments]
self.__cmd += ([] if arguments is None
else [normalize_to_list_of_substitutions(x) for x in arguments])
self.__prefix = normalize_to_list_of_substitutions(
LaunchConfiguration('launch-prefix', default='') if prefix is None else prefix
)
Expand Down
10 changes: 5 additions & 5 deletions launch/test/launch/test_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ def test_executable():

def test_cmd_string_in_list():
exe = Executable(cmd=['ls "my/subdir/with spaces/"'])
exe.prepare(None, LaunchContext())
exe.prepare(LaunchContext(), None)
assert all(a == b for a, b in zip(exe.final_cmd, ['ls "my/subdir/with spaces/"']))


def test_cmd_strings_in_list():
exe = Executable(cmd=['ls', '"my/subdir/with spaces/"'])
exe.prepare(None, LaunchContext())
exe.prepare(LaunchContext(), None)
assert all(a == b for a, b in zip(exe.final_cmd, ['ls', '"my/subdir/with spaces/"']))


def test_cmd_multiple_arguments_in_string():
exe = Executable(cmd=['ls', '-opt1', '-opt2', '-opt3'])
exe.prepare(None, LaunchContext())
exe.prepare(LaunchContext(), None)
assert all(a == b for a, b in zip(exe.final_cmd, ['ls', '-opt1', '-opt2', '-opt3']))


Expand All @@ -55,7 +55,7 @@ def test_passthrough_properties():
cwd = 'cwd'
env = {'a': '1'}
exe = Executable(cmd=['test'], name=name, cwd=cwd, env=env)
exe.prepare(None, LaunchContext())
exe.prepare(LaunchContext(), None)
assert exe.final_name.startswith(name)
assert exe.final_cwd == cwd
assert exe.final_env == env
Expand All @@ -70,7 +70,7 @@ def test_substituted_properties():
cwd = EnvironmentVariable('EXECUTABLE_CWD')
env = {EnvironmentVariable('EXECUTABLE_ENVVAR'): EnvironmentVariable('EXECUTABLE_ENVVAL')}
exe = Executable(cmd=['test'], name=name, cwd=cwd, env=env)
exe.prepare(None, LaunchContext())
exe.prepare(LaunchContext(), None)
assert exe.final_name.startswith('name')
assert exe.final_cwd == 'cwd'
assert exe.final_env == {'var': 'value'}
Expand Down

0 comments on commit dc7f80b

Please sign in to comment.