summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2018-10-25 12:01:17 +0100
committerBenjamin Schubert <bschubert15@bloomberg.net>2018-10-25 18:40:55 +0100
commit02663211c6bcc76a055825fc4f72cbee7c04fbbf (patch)
treec33ade83c6b2c41bbd2cc392f1158e69f5235ee6
parent356d84cdce6c44516d09ab561e10545434e4a609 (diff)
downloadbuildstream-bschubert/fix-command-sandbox.tar.gz
Check if command is a str and replace by list before checking existencebschubert/fix-command-sandbox
Currently we would make sure the sandbox had a command before converting it to a list if it was given as a string. That meant that a string command would never exist and the check be invalid. This also adds the same logic in the dummy sandbox for consistency.
-rw-r--r--buildstream/sandbox/_sandboxbwrap.py8
-rw-r--r--buildstream/sandbox/_sandboxchroot.py8
-rw-r--r--buildstream/sandbox/_sandboxdummy.py4
3 files changed, 12 insertions, 8 deletions
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index fe429abe8..11b2c8296 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -66,15 +66,15 @@ class SandboxBwrap(Sandbox):
cwd = self._get_work_directory(cwd=cwd)
env = self._get_environment(cwd=cwd, env=env)
+ # We want command args as a list of strings
+ if isinstance(command, str):
+ command = [command]
+
if not self._has_command(command[0], env):
raise SandboxError("Staged artifacts do not provide command "
"'{}'".format(command[0]),
reason='missing-command')
- # We want command args as a list of strings
- if isinstance(command, str):
- command = [command]
-
# Create the mount map, this will tell us where
# each mount point needs to be mounted from and to
mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)
diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py
index aeba25137..6057b3a13 100644
--- a/buildstream/sandbox/_sandboxchroot.py
+++ b/buildstream/sandbox/_sandboxchroot.py
@@ -57,15 +57,15 @@ class SandboxChroot(Sandbox):
cwd = self._get_work_directory(cwd=cwd)
env = self._get_environment(cwd=cwd, env=env)
+ # Command must be a list
+ if isinstance(command, str):
+ command = [command]
+
if not self._has_command(command[0], env):
raise SandboxError("Staged artifacts do not provide command "
"'{}'".format(command[0]),
reason='missing-command')
- # Command must be a list
- if isinstance(command, str):
- command = [command]
-
stdout, stderr = self._get_output()
# Create the mount map, this will tell us where
diff --git a/buildstream/sandbox/_sandboxdummy.py b/buildstream/sandbox/_sandboxdummy.py
index 29ff4bf69..cc3700bad 100644
--- a/buildstream/sandbox/_sandboxdummy.py
+++ b/buildstream/sandbox/_sandboxdummy.py
@@ -33,6 +33,10 @@ class SandboxDummy(Sandbox):
cwd = self._get_work_directory(cwd=cwd)
env = self._get_environment(cwd=cwd, env=env)
+ # Command must be a list
+ if isinstance(command, str):
+ command = [command]
+
if not self._has_command(command[0], env):
raise SandboxError("Staged artifacts do not provide command "
"'{}'".format(command[0]),