summaryrefslogtreecommitdiff
path: root/tests/frontend
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-05-04 16:26:50 +0200
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-06-08 21:07:22 +0000
commitaf10c1ba62ebf030511ccb38ae58b7baffa4032f (patch)
treeda6dd78dc0d13b04e1808fbec2436f459fb295b0 /tests/frontend
parent8f2bf4e6e97f3ff859653c6cf60010ce9a2ebca0 (diff)
downloadbuildstream-af10c1ba62ebf030511ccb38ae58b7baffa4032f.tar.gz
Interpret names as colon separated junction path in loader.
'a.bst:b.bst' gets interpreted as 'b.bst' from junction 'a.bst'. Part of #359.
Diffstat (limited to 'tests/frontend')
-rw-r--r--tests/frontend/buildcheckout.py19
-rw-r--r--tests/frontend/fetch.py38
-rw-r--r--tests/frontend/pull.py34
-rw-r--r--tests/frontend/push.py25
-rw-r--r--tests/frontend/show.py47
5 files changed, 159 insertions, 4 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 3eb98139f..5b46d3d52 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -390,3 +390,22 @@ def test_build_checkout_workspaced_junction(cli, tmpdir, datafiles):
with open(filename, 'r') as f:
contents = f.read()
assert contents == 'animal=Horsy\n'
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_build_checkout_cross_junction(datafiles, cli, tmpdir):
+ 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')
+ checkout = os.path.join(cli.directory, 'checkout')
+
+ generate_junction(tmpdir, subproject_path, junction_path)
+
+ result = cli.run(project=project, args=['build', 'junction.bst:import-etc.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project, args=['checkout', 'junction.bst:import-etc.bst', checkout])
+ result.assert_success()
+
+ filename = os.path.join(checkout, 'etc', 'animal.conf')
+ assert os.path.exists(filename)
diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py
index e074dadae..ee3a3c3d5 100644
--- a/tests/frontend/fetch.py
+++ b/tests/frontend/fetch.py
@@ -157,3 +157,41 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage):
# 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)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
+@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
+def test_fetch_cross_junction(cli, tmpdir, datafiles, ref_storage, kind):
+ project = str(datafiles)
+ subproject_path = os.path.join(project, 'files', 'sub-project')
+ junction_path = os.path.join(project, 'elements', 'junction.bst')
+
+ import_etc_path = os.path.join(subproject_path, 'elements', 'import-etc-repo.bst')
+ etc_files_path = os.path.join(subproject_path, 'files', 'etc-files')
+
+ repo = create_repo(kind, str(tmpdir.join('import-etc')))
+ ref = repo.create(etc_files_path)
+
+ element = {
+ 'kind': 'import',
+ 'sources': [
+ repo.source_config(ref=(ref if ref_storage == 'inline' else None))
+ ]
+ }
+ _yaml.dump(element, import_etc_path)
+
+ configure_project(project, {
+ 'ref-storage': ref_storage
+ })
+
+ generate_junction(tmpdir, subproject_path, junction_path, store_ref=(ref_storage == 'inline'))
+
+ if ref_storage == 'project.refs':
+ result = cli.run(project=project, args=['track', 'junction.bst'])
+ result.assert_success()
+ result = cli.run(project=project, args=['track', 'junction.bst:import-etc.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project, args=['fetch', 'junction.bst:import-etc.bst'])
+ result.assert_success()
diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py
index c3ebe41c7..c43cc83e3 100644
--- a/tests/frontend/pull.py
+++ b/tests/frontend/pull.py
@@ -4,6 +4,8 @@ import pytest
from tests.testutils import cli, create_artifact_share
from tests.testutils.site import IS_LINUX
+from . import generate_junction
+
# Project directory
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -276,3 +278,35 @@ def test_push_pull_track_non_strict(cli, tmpdir, datafiles):
result = cli.run(project=project, args=['build', '--track-all', '--all', 'target.bst'])
result.assert_success()
assert set(result.get_pulled_elements()) == all_elements
+
+
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_push_pull_cross_junction(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ share = create_artifact_share(os.path.join(str(tmpdir), 'artifactshare'))
+ subproject_path = os.path.join(project, 'files', 'sub-project')
+ junction_path = os.path.join(project, 'elements', 'junction.bst')
+
+ generate_junction(tmpdir, subproject_path, junction_path, store_ref=True)
+
+ # First build the target element and push to the remote.
+ cli.configure({
+ 'artifacts': {'url': share.repo, 'push': True}
+ })
+ result = cli.run(project=project, args=['build', 'junction.bst:import-etc.bst'])
+ result.assert_success()
+ assert cli.get_element_state(project, 'junction.bst:import-etc.bst') == 'cached'
+
+ cache_dir = os.path.join(project, 'cache', 'artifacts')
+ shutil.rmtree(cache_dir)
+
+ share.update_summary()
+ assert cli.get_element_state(project, 'junction.bst:import-etc.bst') == 'buildable'
+
+ # Now try bst pull
+ result = cli.run(project=project, args=['pull', 'junction.bst:import-etc.bst'])
+ result.assert_success()
+
+ # And assert that it's again in the local cache, without having built
+ assert cli.get_element_state(project, 'junction.bst:import-etc.bst') == 'cached'
diff --git a/tests/frontend/push.py b/tests/frontend/push.py
index 3d40c7deb..ca46b0447 100644
--- a/tests/frontend/push.py
+++ b/tests/frontend/push.py
@@ -7,6 +7,8 @@ from unittest.mock import MagicMock
from buildstream._exceptions import ErrorDomain
from tests.testutils import cli, create_artifact_share, create_element_size
from tests.testutils.site import IS_LINUX
+from . import configure_project, generate_junction
+
# Project directory
DATA_DIR = os.path.join(
@@ -377,3 +379,26 @@ def test_recently_pulled_artifact_does_not_expire(cli, datafiles, tmpdir):
# Ensure that element2 was deleted from the share and element1 remains
assert_not_shared(cli, share, project, 'element2.bst')
assert_shared(cli, share, project, 'element1.bst')
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_push_cross_junction(cli, tmpdir, datafiles):
+ project = str(datafiles)
+ subproject_path = os.path.join(project, 'files', 'sub-project')
+ junction_path = os.path.join(project, 'elements', 'junction.bst')
+
+ generate_junction(tmpdir, subproject_path, junction_path, store_ref=True)
+
+ result = cli.run(project=project, args=['build', 'junction.bst:import-etc.bst'])
+ result.assert_success()
+
+ assert cli.get_element_state(project, 'junction.bst:import-etc.bst') == 'cached'
+
+ share = create_artifact_share(os.path.join(str(tmpdir), 'artifactshare'))
+ cli.configure({
+ 'artifacts': {'url': share.repo, 'push': True},
+ })
+ result = cli.run(project=project, args=['push', 'junction.bst:import-etc.bst'])
+
+ cache_key = cli.get_element_key(project, 'junction.bst:import-etc.bst')
+ assert share.has_artifact('subtest', 'import-etc.bst', cache_key)
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index 719dadbf4..0276961ab 100644
--- a/tests/frontend/show.py
+++ b/tests/frontend/show.py
@@ -111,7 +111,8 @@ def test_target_is_dependency(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
-def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage):
+@pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst'])
+def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage, element_name):
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')
@@ -155,14 +156,15 @@ def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage):
# Assert the correct error when trying to show the pipeline
result = cli.run(project=project, silent=True, args=[
- 'show', 'junction-dep.bst'])
+ 'show', element_name])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_FETCH_NEEDED)
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
-def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage):
+@pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst'])
+def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, element_name):
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')
@@ -190,6 +192,43 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage):
# Assert the correct error when trying to show the pipeline
result = cli.run(project=project, silent=True, args=[
- 'show', 'junction-dep.bst'])
+ 'show', element_name])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst'])
+def test_fetched_junction(cli, tmpdir, datafiles, element_name):
+ 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')
+
+ # Create a repo to hold the subproject and generate a junction element for it
+ generate_junction(tmpdir, subproject_path, junction_path, store_ref=True)
+
+ # 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)
+
+ result = cli.run(project=project, silent=True, args=[
+ 'fetch', 'junction.bst'])
+
+ result.assert_success()
+
+ # Assert the correct error when trying to show the pipeline
+ result = cli.run(project=project, silent=True, args=[
+ 'show', '--format', '%{name}-%{state}', element_name])
+
+ results = result.output.strip().splitlines()
+ assert 'junction.bst:import-etc.bst-buildable' in results