summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarius Makovsky <traveltissues@protonmail.com>2019-11-05 09:45:26 +0000
committerDarius Makovsky <traveltissues@protonmail.com>2019-11-05 12:04:17 +0000
commit659e56766415d4eb94be2849bb63fc67f88b90ca (patch)
tree19995eaf229692fb4a328c35c4898602036d7448
parent247f37548855bd716c4e15508ed5ae33073a868f (diff)
downloadbuildstream-traveltissues/1182.tar.gz
Remove `commit`ting sources inside `Source()._generate_key`traveltissues/1182
`Stream.shell()` should check that the element's sources are cached before calling the shell. If the sources are not cached raise a StreamError and recommend a fetch. closes #1182
-rw-r--r--src/buildstream/_stream.py6
-rw-r--r--src/buildstream/source.py4
-rw-r--r--tests/integration/shell.py4
-rw-r--r--tests/sourcecache/staging.py3
4 files changed, 11 insertions, 6 deletions
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index c71bec80a..4824c7d81 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -188,6 +188,12 @@ class Stream():
# in which case we just blindly trust the directory, using the element
# definitions to control the execution environment only.
if directory is None:
+
+ if not element._source_cached():
+ raise StreamError(
+ "Sources for element {} are not cached."
+ "Element must be fetched.".format(element._get_full_name()))
+
missing_deps = [
dep for dep in self._pipeline.dependencies([element], scope)
if not dep._cached()
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 0312517c9..5321363a4 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -1118,10 +1118,6 @@ class Source(Plugin):
self.__key = generate_key(keys)
- sourcecache = self._get_context().sourcecache
- if self.BST_KEY_REQUIRES_STAGE and not sourcecache.contains(self):
- sourcecache.commit(self, [])
-
@property
def _key(self):
return self.__key
diff --git a/tests/integration/shell.py b/tests/integration/shell.py
index a44f51609..49e9a5950 100644
--- a/tests/integration/shell.py
+++ b/tests/integration/shell.py
@@ -320,6 +320,10 @@ def test_workspace_visible(cli, datafiles):
# that we got the same content here
#
result = cli.run(project=project, args=[
+ 'source', 'fetch', element_name])
+ assert result.exit_code == 0
+
+ result = cli.run(project=project, args=[
'shell', '--build', element_name, '--', 'cat', 'hello.c'
])
assert result.exit_code == 0
diff --git a/tests/sourcecache/staging.py b/tests/sourcecache/staging.py
index b0cc03119..186a4bd9f 100644
--- a/tests/sourcecache/staging.py
+++ b/tests/sourcecache/staging.py
@@ -138,8 +138,7 @@ def test_staged_source_build(tmpdir, datafiles, cli):
element = project.load_elements(["import-dev.bst"])[0]
# check consistency of the source
- # local sources set BST_KEY_REQUIRES_STAGE so this is cached
- assert element._source_cached()
+ assert not element._source_cached()
res = cli.run(project=project_dir, args=['build', 'target.bst'])
res.assert_success()