summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarius Makovsky <traveltissues@protonmail.com>2019-10-07 11:06:13 +0100
committerDarius Makovsky <traveltissues@protonmail.com>2019-10-08 11:55:13 +0100
commit3d9458605ca87a87c9170d80cee4fecac19a0a67 (patch)
tree55394906f333e61e286fc20e207bd20f19c927dc
parent97cd51d6d018c43d32ca433f0bcad7cf0dd77ca0 (diff)
downloadbuildstream-traveltissues/1159.tar.gz
Defer committing workspace files to cachetraveltissues/1159
Remove XFAIL mark from test_workspace_visible and remove the explicit SourceCache.commit() in the workspace source plugin. Allow buildstream to handle the commit logic. Add handling for non-cached workspace sources in `source.Source._generate_keys()`.
-rw-r--r--src/buildstream/plugins/sources/workspace.py13
-rw-r--r--src/buildstream/source.py6
-rw-r--r--tests/integration/shell.py1
3 files changed, 10 insertions, 10 deletions
diff --git a/src/buildstream/plugins/sources/workspace.py b/src/buildstream/plugins/sources/workspace.py
index ee145babb..0e7797fe8 100644
--- a/src/buildstream/plugins/sources/workspace.py
+++ b/src/buildstream/plugins/sources/workspace.py
@@ -89,10 +89,10 @@ class WorkspaceSource(Source):
pass # pragma: nocover
def get_unique_key(self) -> (str, SourceRef):
- sourcecache = self._get_context().sourcecache
+ cas = self._get_context().get_cascache()
if self.__cas_dir is None:
- self.__cas_dir = CasBasedDirectory(sourcecache.cas)
+ self.__cas_dir = CasBasedDirectory(cas)
if self.__digest is None:
@@ -103,14 +103,9 @@ class WorkspaceSource(Source):
"Failed to stage source: files clash with existing directory",
reason='ensure-stage-dir-fail')
self.__digest = self.__cas_dir._get_digest().hash
-
- # commit to cache if not cached
- if not sourcecache.contains(self):
- sourcecache.commit(self, [])
-
# now close down grpc channels
- sourcecache.cas.close_channel()
- assert not sourcecache.cas.has_open_grpc_channels()
+ cas.close_channel()
+ assert not cas.has_open_grpc_channels()
return (self.path, self.__digest)
def init_workspace(self, directory: Directory) -> None:
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index cea68d57e..f4b682616 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -1082,6 +1082,12 @@ class Source(Plugin):
self.__key = generate_key(keys)
+ sourcecache = self._get_context().sourcecache
+ if self.get_kind() == 'workspace' and not sourcecache.contains(self):
+ sourcecache.commit(self, [])
+ sourcecache.cas.close_channel()
+ assert not sourcecache.cas.has_open_grpc_channels()
+
@property
def _key(self):
return self.__key
diff --git a/tests/integration/shell.py b/tests/integration/shell.py
index 50d7f0858..b0de76ef5 100644
--- a/tests/integration/shell.py
+++ b/tests/integration/shell.py
@@ -295,7 +295,6 @@ def test_cli_mount(cli, datafiles, path):
# Test that we can see the workspace files in a shell
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
-@pytest.mark.xfail(strict=True)
def test_workspace_visible(cli, datafiles):
project = str(datafiles)
workspace = os.path.join(cli.directory, 'workspace')