Skip to content

Commit

Permalink
Unit test fixes
Browse files Browse the repository at this point in the history
Distro A; OPSEC #4584

Signed-off-by: Roger Strain <[email protected]>
  • Loading branch information
Roger Strain committed Dec 1, 2020
1 parent 7672671 commit 4ece931
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion launch/launch/actions/execute_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(
self,
*,
cmd: Iterable[SomeSubstitutionsType],
prefix: Optional[SomeSubstitutionsType] = None,
name: Optional[SomeSubstitutionsType] = None,
cwd: Optional[SomeSubstitutionsType] = None,
env: Optional[Dict[SomeSubstitutionsType, SomeSubstitutionsType]] = None,
Expand Down Expand Up @@ -143,7 +144,7 @@ def __init__(
Defaults to 'False'.
:param: respawn_delay a delay time to relaunch the died process if respawn is 'True'.
"""
self.__executable = Executable(cmd=cmd, name=name, cwd=cwd, env=env,
self.__executable = Executable(cmd=cmd, prefix=prefix, name=name, cwd=cwd, env=env,
additional_env=additional_env)
super().__init__(process_description=self.__executable, **kwargs)

Expand Down Expand Up @@ -286,21 +287,29 @@ def parse(
@property
def name(self):
"""Getter for name."""
if self.__executable.final_name is not None:
return self.__executable.final_name
return self.__executable.name

@property
def cmd(self):
"""Getter for cmd."""
if self.__executable.final_cmd is not None:
return self.__executable.final_cmd
return self.__executable.cmd

@property
def cwd(self):
"""Getter for cwd."""
if self.__executable.final_cwd is not None:
return self.__executable.final_cwd
return self.__executable.cwd

@property
def env(self):
"""Getter for env."""
if self.__executable.final_env is not None:
return self.__executable.final_env
return self.__executable.env

@property
Expand Down
6 changes: 5 additions & 1 deletion launch/launch/descriptions/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def __init__(
self.__additional_env.append((
normalize_to_list_of_substitutions(key),
normalize_to_list_of_substitutions(value)))
self.__final_cmd = None
self.__final_cwd = None
self.__final_env = None
self.__final_name = None

@property
def name(self):
Expand Down Expand Up @@ -162,7 +166,7 @@ def __expand_substitutions(self, context):
with _executable_process_counter_lock:
global _executable_process_counter
_executable_process_counter += 1
self.__final_name = f":{name}-{_executable_process_counter}"
self.__final_name = f"{name}-{_executable_process_counter}"
cwd = None
if self.__cwd is not None:
cwd = ''.join([context.perform_substitution(x) for x in self.__cwd])
Expand Down

0 comments on commit 4ece931

Please sign in to comment.