summaryrefslogtreecommitdiff
path: root/tests/frontend/track.py
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-20 10:15:35 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-26 18:27:58 +0000
commit7a928a14d3357543789dc22b2f4c2a04f7a89594 (patch)
tree84222d2d3583e5210370b9f3a2defdb5fc180424 /tests/frontend/track.py
parent85d13fc458097e7db05a7c4efdb0cd9c75126727 (diff)
downloadbuildstream-7a928a14d3357543789dc22b2f4c2a04f7a89594.tar.gz
tests: ensure provenance for _get_loader errors
Make the tests that currently cover _get_loader ensure that we are getting the expected provenance. Note that for some tests, we must use yaml_file_get_provenance, as the generated yaml is not stable across versions of ruamel. In later work we may replace all instances of provenance string tests with yaml_file_get_provenance, as it will be more robust to future changes.
Diffstat (limited to 'tests/frontend/track.py')
-rw-r--r--tests/frontend/track.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
index 5a6460d3d..13d1d4646 100644
--- a/tests/frontend/track.py
+++ b/tests/frontend/track.py
@@ -4,7 +4,7 @@
import stat
import os
import pytest
-from tests.testutils import create_repo, generate_junction
+from tests.testutils import create_repo, generate_junction, yaml_file_get_provenance
from buildstream.plugintestutils import cli # pylint: disable=unused-import
from buildstream._exceptions import ErrorDomain, LoadErrorReason
@@ -274,6 +274,11 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage):
result = cli.run(project=project, args=['source', 'track', 'junction-dep.bst'])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT)
+ # Assert that we have the expected provenance encoded into the error
+ provenance = yaml_file_get_provenance(
+ element_path, 'junction-dep.bst', key='depends', indices=[0])
+ assert str(provenance) in result.stderr
+
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
@@ -307,6 +312,11 @@ def test_junction_element(cli, tmpdir, datafiles, ref_storage):
result = cli.run(project=project, args=['show', 'junction-dep.bst'])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT)
+ # Assert that we have the expected provenance encoded into the error
+ provenance = yaml_file_get_provenance(
+ element_path, 'junction-dep.bst', key='depends', indices=[0])
+ assert str(provenance) in result.stderr
+
# Now track the junction itself
result = cli.run(project=project, args=['source', 'track', 'junction.bst'])
result.assert_success()