diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-05 22:09:19 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-05 22:14:32 +0900 |
commit | ee73a87b9c5c6ca0b1e9aaf55aeaebda5ab43e1e (patch) | |
tree | 245d0a2db66eef4c629f504bf726bfb31b4584f7 /tests | |
parent | 24ab5ce7060ecc2460cdaa75433f8c2a0e9dacf9 (diff) | |
download | buildstream-ee73a87b9c5c6ca0b1e9aaf55aeaebda5ab43e1e.tar.gz |
tests/frontend/track.py: Added junction related tests
o Test that we bail out with the expected errors when the
junction element in question is Consistency.INCONSISTENT
o Test that tracking the junction itself, causes a subsequent
show of the pipeline to not bail out anymore (tests that
tracking works and persists for a junction element).
Again these use both ref-storage modes.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/track.py | 78 |
1 files changed, 76 insertions, 2 deletions
diff --git a/tests/frontend/track.py b/tests/frontend/track.py index 1425183be..6fa61f343 100644 --- a/tests/frontend/track.py +++ b/tests/frontend/track.py @@ -2,10 +2,10 @@ import os import pytest from tests.testutils import cli, create_repo, ALL_REPO_KINDS -from buildstream._exceptions import ErrorDomain +from buildstream._exceptions import ErrorDomain, LoadErrorReason from buildstream import _yaml -from . import configure_project +from . import configure_project, generate_junction # Project directory TOP_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -306,3 +306,77 @@ def test_track_consistency_bug(cli, tmpdir, datafiles): # We expect BuildStream to fail gracefully, with no recorded exception. result.assert_main_error(ErrorDomain.PIPELINE, 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=['track', '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_junction_element(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) + + # First demonstrate that showing the pipeline yields an error + result = cli.run(project=project, args=['show', 'junction-dep.bst']) + result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT) + + # Now track the junction itself + result = cli.run(project=project, args=['track', 'junction.bst']) + result.assert_success() + + # Now assert element state (via bst show under the hood) of the dep again + assert cli.get_element_state(project, 'junction-dep.bst') == 'waiting' |