summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-05 21:56:13 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-05 22:14:32 +0900
commit24ab5ce7060ecc2460cdaa75433f8c2a0e9dacf9 (patch)
tree73a7da9a4dff50842df158f57ae15e1f96e99251
parentabb9ef2220afdc8466d0f6448787a0f8d87e5918 (diff)
downloadbuildstream-24ab5ce7060ecc2460cdaa75433f8c2a0e9dacf9.tar.gz
tests/frontend/fetch.py: Added tests for automatically fetching the junctions
o This tests that a Consistency.RESOLVED junction will automatically be fetched when `bst fetch` is run on a pipeline which refers to a junction. o Further, it tests that a Consistency.INCONSISTENT junction will bail out with the expected error message Again testing with both ref-storage modes
-rw-r--r--tests/frontend/fetch.py88
1 files changed, 87 insertions, 1 deletions
diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py
index 8b44690b4..261e0b22e 100644
--- a/tests/frontend/fetch.py
+++ b/tests/frontend/fetch.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
TOP_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -71,3 +73,87 @@ def test_fetch_consistency_bug(cli, tmpdir, datafiles):
result = cli.run(project=project, args=['fetch', 'bug.bst'])
assert result.exc is not None
assert str(result.exc) == "Something went terribly wrong"
+
+
+@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 fetch it, this should automatically result in fetching
+ # the junction itself.
+ result = cli.run(project=project, args=['fetch', 'junction-dep.bst'])
+ result.assert_success()
+
+
+@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 fetch it, this will bail with the appropriate error
+ # informing the user to track the junction first
+ result = cli.run(project=project, args=['fetch', 'junction-dep.bst'])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT)