summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-06-13 18:02:09 +0100
committerBenjamin Schubert <contact@benschubert.me>2019-06-25 21:08:50 +0100
commitf72971a0776c090e02f18d4c20f87b5c448b8fb0 (patch)
treed2084f833ab514febd6666fe9708b1041f9c6134
parent9e3030ec6b2e8839971273a8405b50d9a0616db9 (diff)
downloadbuildstream-f72971a0776c090e02f18d4c20f87b5c448b8fb0.tar.gz
tests: remove 'node_get_yaml_provenance()' helper and replace with the new API
This function is hard to make generic and, with the new API, the access is simplified. Therefore, removing this function and migrating all its usages
-rw-r--r--tests/frontend/buildcheckout.py7
-rw-r--r--tests/frontend/fetch.py7
-rw-r--r--tests/frontend/show.py7
-rw-r--r--tests/frontend/track.py12
-rw-r--r--tests/testutils/__init__.py1
-rw-r--r--tests/testutils/yaml.py47
6 files changed, 19 insertions, 62 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 97bce91a7..f9cd1cba4 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -15,7 +15,7 @@ from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream import utils
-from tests.testutils import generate_junction, yaml_file_get_provenance, create_artifact_share
+from tests.testutils import generate_junction, create_artifact_share
from . import configure_project
@@ -460,8 +460,9 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage):
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])
+ element_node = _yaml.load(element_path, shortname='junction-dep.bst')
+ ref_node = element_node.get_sequence('depends').mapping_at(0)
+ provenance = _yaml.node_get_provenance(ref_node)
assert str(provenance) in result.stderr
diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py
index f470ce2b7..d7e0ecafb 100644
--- a/tests/frontend/fetch.py
+++ b/tests/frontend/fetch.py
@@ -9,7 +9,7 @@ from buildstream.testing import cli # pylint: disable=unused-import
from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
-from tests.testutils import generate_junction, yaml_file_get_provenance
+from tests.testutils import generate_junction
from . import configure_project
@@ -171,6 +171,7 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage):
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])
+ element_node = _yaml.load(element_path, shortname='junction-dep.bst')
+ ref_node = element_node.get_sequence('depends').mapping_at(0)
+ provenance = _yaml.node_get_provenance(ref_node)
assert str(provenance) in result.stderr
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index 4ef97dd84..4192ba1e5 100644
--- a/tests/frontend/show.py
+++ b/tests/frontend/show.py
@@ -10,7 +10,7 @@ from buildstream.testing import cli # pylint: disable=unused-import
from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
-from tests.testutils import generate_junction, yaml_file_get_provenance
+from tests.testutils import generate_junction
from . import configure_project
@@ -333,8 +333,9 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, workspaced):
etc_result.assert_success()
else:
# 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])
+ element_node = _yaml.load(element_path, shortname='junction-dep.bst')
+ ref_node = element_node.get_sequence('depends').mapping_at(0)
+ provenance = _yaml.node_get_provenance(ref_node)
assert str(provenance) in dep_result.stderr
dep_result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT)
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
index 808bf0593..1163cc687 100644
--- a/tests/frontend/track.py
+++ b/tests/frontend/track.py
@@ -9,7 +9,7 @@ from buildstream.testing import create_repo
from buildstream.testing import cli # pylint: disable=unused-import
from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream import _yaml
-from tests.testutils import generate_junction, yaml_file_get_provenance
+from tests.testutils import generate_junction
from . import configure_project
# Project directory
@@ -275,8 +275,9 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage):
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])
+ element_node = _yaml.load(element_path, shortname='junction-dep.bst')
+ ref_node = element_node.get_sequence('depends').mapping_at(0)
+ provenance = _yaml.node_get_provenance(ref_node)
assert str(provenance) in result.stderr
@@ -313,8 +314,9 @@ def test_junction_element(cli, tmpdir, datafiles, ref_storage):
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])
+ element_node = _yaml.load(element_path, shortname='junction-dep.bst')
+ ref_node = element_node.get_sequence('depends').mapping_at(0)
+ provenance = _yaml.node_get_provenance(ref_node)
assert str(provenance) in result.stderr
# Now track the junction itself
diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py
index 2e1f72138..6ea6cc3e8 100644
--- a/tests/testutils/__init__.py
+++ b/tests/testutils/__init__.py
@@ -28,5 +28,4 @@ from .element_generators import create_element_size, update_element_size
from .junction import generate_junction
from .runner_integration import wait_for_cache_granularity
from .python_repo import setup_pypi_repo
-from .yaml import yaml_file_get_provenance
from .platform import override_platform_uname
diff --git a/tests/testutils/yaml.py b/tests/testutils/yaml.py
deleted file mode 100644
index a1dcb8646..000000000
--- a/tests/testutils/yaml.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Copyright (C) 2019 Bloomberg Finance LP
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-#
-# Authors:
-# Angelos Evripiotis <jevripiotis@bloomberg.net>
-
-from buildstream import _yaml
-
-
-# yaml_file_get_provenance()
-#
-# Load a yaml file and return its _yaml.ProvenanceInformation object.
-#
-# This is useful for checking the provenance in BuildStream output is as
-# expected.
-#
-# Args:
-# path (str): The path to the file to be loaded
-# shortname (str): How the path should appear in the error
-# key (str): Optional key to look up in the loaded file
-# indices (list of indexes): Optional index path, in the case of list values
-#
-# Returns:
-# The ProvenanceInformation of the dict, member or list element
-#
-def yaml_file_get_provenance(path, shortname, key=None, indices=None):
- file_node = _yaml.load(path, shortname)
- if key:
- required_node = _yaml.node_get(file_node, dict, key, indices=indices)
- else:
- required_node = file_node
- provenance = _yaml.node_get_provenance(required_node)
- assert provenance is not None
- return provenance