Jonathan Maw pushed to branch jonathan/workspace-fragment-create at BuildStream / buildstream
Commits:
2 changed files:
Changes:
... | ... | @@ -40,6 +40,7 @@ from .element import Element |
40 | 40 |
from ._message import Message, MessageType
|
41 | 41 |
from ._includes import Includes
|
42 | 42 |
from ._platform import Platform
|
43 |
+from ._workspaces import WorkspaceLocal
|
|
43 | 44 |
|
44 | 45 |
|
45 | 46 |
# Project Configuration file
|
... | ... | @@ -661,11 +662,14 @@ class Project(): |
661 | 662 |
def _find_project_dir(self, directory):
|
662 | 663 |
project_directory = utils._search_upward_for_file(directory, _PROJECT_CONF_FILE)
|
663 | 664 |
if not project_directory:
|
664 |
- # TODO: We can also find the project dir through a workspace
|
|
665 |
- raise LoadError(
|
|
666 |
- LoadErrorReason.MISSING_PROJECT_CONF,
|
|
667 |
- '{} not found in current directory or any of its parent directories'
|
|
668 |
- .format(_PROJECT_CONF_FILE))
|
|
665 |
+ workspace_local = WorkspaceLocal.load(directory)
|
|
666 |
+ if workspace_local:
|
|
667 |
+ project_directory = workspace_local.get_default_path()
|
|
668 |
+ else:
|
|
669 |
+ raise LoadError(
|
|
670 |
+ LoadErrorReason.MISSING_PROJECT_CONF,
|
|
671 |
+ '{} not found in current directory or any of its parent directories'
|
|
672 |
+ .format(_PROJECT_CONF_FILE))
|
|
669 | 673 |
|
670 | 674 |
return project_directory
|
671 | 675 |
|
... | ... | @@ -447,7 +447,9 @@ def test_list(cli, tmpdir, datafiles): |
447 | 447 |
@pytest.mark.datafiles(DATA_DIR)
|
448 | 448 |
@pytest.mark.parametrize("kind", repo_kinds)
|
449 | 449 |
@pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
|
450 |
-def test_build(cli, tmpdir, datafiles, kind, strict):
|
|
450 |
+@pytest.mark.parametrize("call_from", [("project"), ("workspace")])
|
|
451 |
+def test_build(cli, tmpdir_factory, datafiles, kind, strict, call_from):
|
|
452 |
+ tmpdir = tmpdir_factory.mktemp('')
|
|
451 | 453 |
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
|
452 | 454 |
checkout = os.path.join(str(tmpdir), 'checkout')
|
453 | 455 |
|
... | ... | @@ -472,7 +474,8 @@ def test_build(cli, tmpdir, datafiles, kind, strict): |
472 | 474 |
# Build modified workspace
|
473 | 475 |
assert cli.get_element_state(project, element_name) == 'buildable'
|
474 | 476 |
assert cli.get_element_key(project, element_name) == "{:?<64}".format('')
|
475 |
- result = cli.run(project=project, args=['build', element_name])
|
|
477 |
+ result = cli.run(project=project if call_from == "project" else workspace,
|
|
478 |
+ args=['build', element_name])
|
|
476 | 479 |
result.assert_success()
|
477 | 480 |
assert cli.get_element_state(project, element_name) == 'cached'
|
478 | 481 |
assert cli.get_element_key(project, element_name) != "{:?<64}".format('')
|