diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-03-09 20:10:18 +0900 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-12 08:04:52 +0000 |
commit | e8c0cb414abb95bdcb4edb5db44a7b0bcc67da30 (patch) | |
tree | 002347c121f631e6a655643ce1f7bf0c51471b73 | |
parent | efd0b8763205277cec437818eb80c28118711342 (diff) | |
download | buildstream-e8c0cb414abb95bdcb4edb5db44a7b0bcc67da30.tar.gz |
tests/format/junctions.py: Added tests for missing files across junction boundaries
These include assertions for the expected provenance in the errors,
protecting against regressions of #947
11 files changed, 67 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']) diff --git a/tests/loader/junctions/missing-element/junction-A.bst b/tests/loader/junctions/missing-element/junction-A.bst new file mode 100644 index 000000000..74079f990 --- /dev/null +++ b/tests/loader/junctions/missing-element/junction-A.bst @@ -0,0 +1,4 @@ +kind: junction +sources: +- kind: local + path: junctionA diff --git a/tests/loader/junctions/missing-element/junctionA/bad-junction-target.bst b/tests/loader/junctions/missing-element/junctionA/bad-junction-target.bst new file mode 100644 index 000000000..c07c198cd --- /dev/null +++ b/tests/loader/junctions/missing-element/junctionA/bad-junction-target.bst @@ -0,0 +1,5 @@ +kind: manual + +depends: +- filename: noelement.bst + junction: missing-junction.bst diff --git a/tests/loader/junctions/missing-element/junctionA/junction-B.bst b/tests/loader/junctions/missing-element/junctionA/junction-B.bst new file mode 100644 index 000000000..bc66d7851 --- /dev/null +++ b/tests/loader/junctions/missing-element/junctionA/junction-B.bst @@ -0,0 +1,4 @@ +kind: junction +sources: +- kind: local + path: junctionB diff --git a/tests/loader/junctions/missing-element/junctionA/junctionB/project.conf b/tests/loader/junctions/missing-element/junctionA/junctionB/project.conf new file mode 100644 index 000000000..41b8d6c72 --- /dev/null +++ b/tests/loader/junctions/missing-element/junctionA/junctionB/project.conf @@ -0,0 +1 @@ +name: projectB diff --git a/tests/loader/junctions/missing-element/junctionA/project.conf b/tests/loader/junctions/missing-element/junctionA/project.conf new file mode 100644 index 000000000..5f6ab28a2 --- /dev/null +++ b/tests/loader/junctions/missing-element/junctionA/project.conf @@ -0,0 +1 @@ +name: projectA diff --git a/tests/loader/junctions/missing-element/junctionA/target.bst b/tests/loader/junctions/missing-element/junctionA/target.bst new file mode 100644 index 000000000..9c3d0bf0e --- /dev/null +++ b/tests/loader/junctions/missing-element/junctionA/target.bst @@ -0,0 +1,5 @@ +kind: stack + +depends: +- filename: missing.bst + junction: junction-B.bst diff --git a/tests/loader/junctions/missing-element/project.conf b/tests/loader/junctions/missing-element/project.conf new file mode 100644 index 000000000..b32753625 --- /dev/null +++ b/tests/loader/junctions/missing-element/project.conf @@ -0,0 +1 @@ +name: test diff --git a/tests/loader/junctions/missing-element/sub-target-bad-junction.bst b/tests/loader/junctions/missing-element/sub-target-bad-junction.bst new file mode 100644 index 000000000..f48f6cec9 --- /dev/null +++ b/tests/loader/junctions/missing-element/sub-target-bad-junction.bst @@ -0,0 +1,5 @@ +kind: stack + +depends: +- filename: bad-junction-target.bst + junction: junction-A.bst diff --git a/tests/loader/junctions/missing-element/sub-target.bst b/tests/loader/junctions/missing-element/sub-target.bst new file mode 100644 index 000000000..79e8bc684 --- /dev/null +++ b/tests/loader/junctions/missing-element/sub-target.bst @@ -0,0 +1,5 @@ +kind: stack + +depends: +- filename: target.bst + junction: junction-A.bst diff --git a/tests/loader/junctions/missing-element/target.bst b/tests/loader/junctions/missing-element/target.bst new file mode 100644 index 000000000..69ecef75c --- /dev/null +++ b/tests/loader/junctions/missing-element/target.bst @@ -0,0 +1,5 @@ +kind: stack + +depends: +- filename: missing.bst + junction: junction-A.bst |