diff options
-rw-r--r-- | buildstream/element.py | 6 | ||||
-rw-r--r-- | tests/frontend/workspace.py | 29 |
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 |