diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-05-17 14:31:22 +0000 |
---|---|---|
committer | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-05-17 14:31:22 +0000 |
commit | 7abf1073dc8f56c6e217fefb2886832a04323e04 (patch) | |
tree | a76a8c48c63e1ca25dd883e76381346e0fe13934 | |
parent | 8a16aa6f7af238fb77e90c6f4e7d4f1457507b85 (diff) | |
parent | 220404db88b3fc5faae8cc14583ce5a89810cd52 (diff) | |
download | buildstream-7abf1073dc8f56c6e217fefb2886832a04323e04.tar.gz |
Merge branch 'raoul/440-fix' into 'master'
Fix init_workspace for multiple sources
See merge request BuildStream/buildstream!1345
-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 |