Commit 8704363a authored by Tristan Van Berkom's avatar Tristan Van Berkom

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
parent ee73a87b
Pipeline #20029700 failed with stages
in 10 minutes and 52 seconds
......@@ -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'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment