diff options
Diffstat (limited to 'tests/loader/junctions.py')
-rw-r--r-- | tests/loader/junctions.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/loader/junctions.py b/tests/loader/junctions.py index a02961fb5..aee164396 100644 --- a/tests/loader/junctions.py +++ b/tests/loader/junctions.py @@ -3,7 +3,7 @@ import pytest import shutil from buildstream import _yaml, ElementError -from buildstream._exceptions import LoadError, LoadErrorReason +from buildstream._exceptions import ErrorDomain, LoadError, LoadErrorReason from tests.testutils import cli, create_repo from tests.testutils.site import HAVE_GIT @@ -48,6 +48,36 @@ def test_simple_build(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) +def test_missing_file_in_subproject(cli, datafiles): + project = os.path.join(str(datafiles), 'missing-element') + result = cli.run(project=project, args=['show', 'target.bst']) + result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE) + + # Assert that we have the expected provenance encoded into the error + assert "target.bst [line 4 column 2]" in result.stderr + + +@pytest.mark.datafiles(DATA_DIR) +def test_missing_file_in_subsubproject(cli, datafiles): + project = os.path.join(str(datafiles), 'missing-element') + result = cli.run(project=project, args=['show', 'sub-target.bst']) + result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE) + + # Assert that we have the expected provenance encoded into the error + assert "junction-A.bst:target.bst [line 4 column 2]" in result.stderr + + +@pytest.mark.datafiles(DATA_DIR) +def test_missing_junction_in_subproject(cli, datafiles): + project = os.path.join(str(datafiles), 'missing-element') + result = cli.run(project=project, args=['show', 'sub-target-bad-junction.bst']) + result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE) + + # Assert that we have the expected provenance encoded into the error + assert "junction-A.bst:bad-junction-target.bst [line 4 column 2]" in result.stderr + + +@pytest.mark.datafiles(DATA_DIR) def test_nested_simple(cli, tmpdir, datafiles): foo = os.path.join(str(datafiles), 'foo') copy_subprojects(foo, datafiles, ['base']) |