Skip to content
Snippets Groups Projects
Verified Commit 9cce211d authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

ShellClient now considers _workspace.bindirs when searching for programs

parent 262bb791
No related branches found
No related tags found
1 merge request!80Resolve "Don't use popen directly in integration tests"
......@@ -140,6 +140,32 @@ def _process_exists(pid):
return True
def _find_search_paths(additional_paths=None):
"""
Return the entire list of search paths available to the process. If
additional_paths is not provided, $PATH env is returned.
Parameters
----------
additional_paths: `list`
If provided, additional paths that should be used for searching before
falling back to the contents of $PATH.
Returns
-------
A list containing the paths that should be searched for commands.
"""
paths_to_search = []
if isinstance(additional_paths, (tuple, list)):
paths_to_search.extend(additional_paths)
env_paths = os.environ.get("PATH", "").split(os.pathsep)
paths_to_search.extend(env_paths)
return paths_to_search
class FwdDaemonCreator:
"""
Factory that allows tests to create forwarding daemons in a workspace.
......@@ -439,6 +465,7 @@ class ShellClient:
def __init__(self, workspace):
self._workspace = workspace
self._search_paths = _find_search_paths(self._workspace.bindirs)
self._cmd = sh.Command("bash")
self._env = os.environ.copy()
......@@ -608,9 +635,12 @@ class ShellClient:
extra properties to it.
"""
cmd = sh.which(cmd, self._search_paths)
bash_c_args = f"{cmd} {' '.join(str(a) for a in args)}"
logger.debug(f"running bash")
logger.debug(f"cmd: bash -c '{bash_c_args}'")
logger.debug(f"search_paths: {':'.join(str(p) for p in self._search_paths)}")
logger.debug(f"timeout: {timeout} seconds")
logger.debug(f"timeout_signal: {signal.Signals(timeout_signal).name}")
logger.debug(f"patched env:\n{pformat(self._patched_env)}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment