summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-05 22:27:16 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-05 22:27:16 +0900
commit8704363a2c3d94bbc40240e1363d72bacfd96e53 (patch)
tree6964fe921d90d2d852a97f80e0daa4a50760c7e2
parentee73a87b9c5c6ca0b1e9aaf55aeaebda5ab43e1e (diff)
downloadbuildstream-8704363a2c3d94bbc40240e1363d72bacfd96e53.tar.gz
tests/frontend/buildcheckout.py: Added junction related tests
o Test that we get the expected error if the junction element the pipeline refers to is inconsistent o Test that the junction element is automatically fetched as a part of the build phase Both tests using both ref-storage modes
-rw-r--r--tests/frontend/buildcheckout.py91
1 files changed, 90 insertions, 1 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 1a5b08caa..c24a82b1b 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -3,7 +3,9 @@ import pytest
from tests.testutils import cli, create_repo, ALL_REPO_KINDS
from buildstream import _yaml
-from buildstream._exceptions import ErrorDomain
+from buildstream._exceptions import ErrorDomain, LoadErrorReason
+
+from . import configure_project, generate_junction
# Project directory
DATA_DIR = os.path.join(
@@ -192,3 +194,90 @@ def test_install_to_build(cli, tmpdir, datafiles):
result.assert_main_error(ErrorDomain.PIPELINE, None)
result.assert_task_error(ErrorDomain.ELEMENT, None)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
+def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ subproject_path = os.path.join(project, 'files', 'sub-project')
+ junction_path = os.path.join(project, 'elements', 'junction.bst')
+ element_path = os.path.join(project, 'elements', 'junction-dep.bst')
+
+ configure_project(project, {
+ 'ref-storage': ref_storage
+ })
+
+ # Create a repo to hold the subproject and generate a junction element for it
+ generate_junction(tmpdir, subproject_path, junction_path, store_ref=False)
+
+ # Create a stack element to depend on a cross junction element
+ #
+ element = {
+ 'kind': 'stack',
+ 'depends': [
+ {
+ 'junction': 'junction.bst',
+ 'filename': 'import-etc.bst'
+ }
+ ]
+ }
+ _yaml.dump(element, element_path)
+
+ # Now try to track it, this will bail with the appropriate error
+ # informing the user to track the junction first
+ result = cli.run(project=project, args=['build', 'junction-dep.bst'])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
+def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ subproject_path = os.path.join(project, 'files', 'sub-project')
+ junction_path = os.path.join(project, 'elements', 'junction.bst')
+ element_path = os.path.join(project, 'elements', 'junction-dep.bst')
+
+ configure_project(project, {
+ 'ref-storage': ref_storage
+ })
+
+ # Create a repo to hold the subproject and generate a junction element for it
+ ref = generate_junction(tmpdir, subproject_path, junction_path, store_ref=(ref_storage == 'inline'))
+
+ # Create a stack element to depend on a cross junction element
+ #
+ element = {
+ 'kind': 'stack',
+ 'depends': [
+ {
+ 'junction': 'junction.bst',
+ 'filename': 'import-etc.bst'
+ }
+ ]
+ }
+ _yaml.dump(element, element_path)
+
+ # Dump a project.refs if we're using project.refs storage
+ #
+ if ref_storage == 'project.refs':
+ project_refs = {
+ 'projects': {
+ 'test': {
+ 'junction.bst': [
+ {
+ 'ref': ref
+ }
+ ]
+ }
+ }
+ }
+ _yaml.dump(project_refs, os.path.join(project, 'project.refs'))
+
+ # Now try to build it, this should automatically result in fetching
+ # the junction itself at load time.
+ result = cli.run(project=project, args=['build', 'junction-dep.bst'])
+ result.assert_success()
+
+ # Assert that it's cached now
+ assert cli.get_element_state(project, 'junction-dep.bst') == 'cached'