summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-11-27 14:12:31 +0100
committerJürg Billeter <j@bitron.ch>2019-11-27 16:21:45 +0100
commit3a03fe664cea92e880f0703a3bf59929afca7b50 (patch)
treef20af4d81b00ae39bc11ffc3841b0150456592ab
parent5c54a559ec19c11f570aa7b3fb336c7afd61ef51 (diff)
downloadbuildstream-3a03fe664cea92e880f0703a3bf59929afca7b50.tar.gz
sandbox.py: Assert that the working directory is an absolute path
Sandbox implementations rely on this.
-rw-r--r--src/buildstream/sandbox/sandbox.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py
index c88cbf977..804759416 100644
--- a/src/buildstream/sandbox/sandbox.py
+++ b/src/buildstream/sandbox/sandbox.py
@@ -305,6 +305,8 @@ class Sandbox:
cwd = self._get_work_directory(cwd=cwd)
env = self._get_environment(cwd=cwd, env=env)
+ assert cwd.startswith("/"), "The working directory must be an absolute path"
+
# Convert single-string argument to a list
if isinstance(command, str):
command = [command]
@@ -520,7 +522,7 @@ class Sandbox:
#
# Returns:
# (str): The sandbox work directory
- def _get_work_directory(self, *, cwd=None):
+ def _get_work_directory(self, *, cwd=None) -> str:
return cwd or self.__cwd or "/"
# _get_scratch_directory()