summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2019-05-16 15:09:42 +0100
committerJames Ennis <james.ennis@codethink.com>2019-05-17 07:33:15 +0000
commit220404db88b3fc5faae8cc14583ce5a89810cd52 (patch)
treea76a8c48c63e1ca25dd883e76381346e0fe13934
parent8a16aa6f7af238fb77e90c6f4e7d4f1457507b85 (diff)
downloadbuildstream-raoul/440-fix.tar.gz
element.py: fix init_workspace for multiple sourcesraoul/440-fix
Noticed a mistake that got into !1214, so only the last source gets initialised in a workspace. Added a test for this.
-rw-r--r--buildstream/element.py6
-rw-r--r--tests/frontend/workspace.py29
2 files changed, 30 insertions, 5 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 8c507b768..c652015e4 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1993,12 +1993,8 @@ class Element(Plugin):
os.makedirs(context.builddir, exist_ok=True)
with utils._tempdir(dir=context.builddir, prefix='workspace-{}'
.format(self.normal_name)) as temp:
- last_source = None
for source in self.sources():
- last_source = source
-
- if last_source:
- last_source._init_workspace(temp)
+ source._init_workspace(temp)
# Now hardlink the files into the workspace target.
utils.link_files(temp, workspace.get_absolute_path())
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 1db23ccc4..0f5d73db8 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -1231,6 +1231,35 @@ def test_external_list(cli, datafiles, tmpdir_factory):
result.assert_success()
+@pytest.mark.datafiles(DATA_DIR)
+def test_multisource_workspace(cli, datafiles, tmpdir):
+ # checks that if an element has multiple sources, then the opened workspace
+ # will contain them
+ project = str(datafiles)
+ element_name = "multisource.bst"
+ element = {
+ 'kind': 'import',
+ 'sources': [{
+ 'kind': 'local',
+ 'path': 'files/bin-files'
+ }, {
+ 'kind': 'local',
+ 'path': 'files/dev-files'
+ }]
+ }
+ element_path = os.path.join(project, 'elements', element_name)
+ _yaml.dump(element, element_path)
+
+ workspace_dir = os.path.join(str(tmpdir), 'multisource')
+ res = cli.run(project=project,
+ args=['workspace', 'open', 'multisource.bst',
+ '--directory', workspace_dir])
+ res.assert_success()
+
+ directories = os.listdir(os.path.join(workspace_dir, 'usr'))
+ assert 'bin' in directories and 'include' in directories
+
+
# This strange test tests against a regression raised in issue #919,
# where opening a workspace on a runtime dependency of a build only
# dependency causes `bst build` to not build the specified target