You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:38:32 UTC

[buildstream] 01/20: Add some more asserts to check early that we're not doing the wrong thing with CAS

This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch jmac/virtual_directory_tests
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 6eacca219fe79c0cce97fa0f5c33b942904bc8e6
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Fri Sep 14 13:38:41 2018 +0100

    Add some more asserts to check early that we're not doing the wrong thing with CAS
---
 buildstream/sandbox/_mount.py         | 3 ++-
 buildstream/sandbox/_sandboxbwrap.py  | 5 ++++-
 buildstream/sandbox/_sandboxremote.py | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/buildstream/sandbox/_mount.py b/buildstream/sandbox/_mount.py
index 49068fe..b516d89 100644
--- a/buildstream/sandbox/_mount.py
+++ b/buildstream/sandbox/_mount.py
@@ -23,7 +23,7 @@ from contextlib import contextmanager, ExitStack
 
 from .. import utils
 from .._fuse import SafeHardlinks
-
+from ..storage import CasBasedDirectory
 
 # Mount()
 #
@@ -35,6 +35,7 @@ class Mount():
         # Getting _get_underlying_directory() here is acceptable as
         # we're part of the sandbox code. This will fail if our
         # directory is CAS-based.
+        assert not isinstance(sandbox.get_virtual_directory(), CasBasedDirectory)
         root_directory = sandbox.get_virtual_directory()._get_underlying_directory()
 
         self.mount_point = mount_point
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index 88b697d..1047828 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -32,7 +32,7 @@ from .._exceptions import SandboxError
 from .. import utils, _signals
 from ._mount import MountMap
 from . import Sandbox, SandboxFlags
-
+from ..storage import CasBasedDirectory
 
 # SandboxBwrap()
 #
@@ -57,6 +57,9 @@ class SandboxBwrap(Sandbox):
     def run(self, command, flags, *, cwd=None, env=None):
         stdout, stderr = self._get_output()
 
+        # We cannot run directly from CAS-based directories at the moment.
+        assert not isinstance(self.get_virtual_directory(), CasBasedDirectory)
+
         # Allowable access to underlying storage as we're part of the sandbox
         root_directory = self.get_virtual_directory()._get_underlying_directory()
 
diff --git a/buildstream/sandbox/_sandboxremote.py b/buildstream/sandbox/_sandboxremote.py
index 296b203..572ee5f 100644
--- a/buildstream/sandbox/_sandboxremote.py
+++ b/buildstream/sandbox/_sandboxremote.py
@@ -172,6 +172,7 @@ class SandboxRemote(Sandbox):
         if isinstance(upload_vdir, FileBasedDirectory):
             # Make a new temporary directory to put source in
             upload_vdir = CasBasedDirectory(self._get_context(), ref=None)
+            assert not isinstance(self.get_virtual_directory(), CasBasedDirectory)
             upload_vdir.import_files(self.get_virtual_directory()._get_underlying_directory())
 
         upload_vdir.recalculate_hash()