From 0fbff08bbe4611e2497b197d69b2ed362ce1294b Mon Sep 17 00:00:00 2001 From: Lachlan Mackenzie <lachlan.mackenzie@codethink.co.uk> Date: Tue, 2 Oct 2018 15:00:10 +0100 Subject: [PATCH] yaml.py: Add yaml cache testing to yaml list composition test --- tests/yaml/yaml.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/yaml/yaml.py b/tests/yaml/yaml.py index 70a8310c08..c0184431b3 100644 --- a/tests/yaml/yaml.py +++ b/tests/yaml/yaml.py @@ -5,6 +5,8 @@ from collections import Mapping from buildstream import _yaml from buildstream._exceptions import LoadError, LoadErrorReason +from buildstream._context import Context +from buildstream._yamlcache import YamlCache DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), @@ -181,6 +183,7 @@ def load_yaml_file(filename, *, cache_path, shortname=None, from_cache='raw'): # prov_col: The expected provenance column of "mood" # @pytest.mark.datafiles(os.path.join(DATA_DIR)) +@pytest.mark.parametrize('caching', [('raw'), ('cached')]) @pytest.mark.parametrize("filename,index,length,mood,prov_file,prov_line,prov_col", [ # Test results of compositing with the (<) prepend directive @@ -211,14 +214,15 @@ def load_yaml_file(filename, *, cache_path, shortname=None, from_cache='raw'): ('implicitoverwrite.yaml', 0, 2, 'overwrite1', 'implicitoverwrite.yaml', 4, 8), ('implicitoverwrite.yaml', 1, 2, 'overwrite2', 'implicitoverwrite.yaml', 6, 8), ]) -def test_list_composition(datafiles, filename, +def test_list_composition(datafiles, filename, tmpdir, index, length, mood, - prov_file, prov_line, prov_col): - base = os.path.join(datafiles.dirname, datafiles.basename, 'basics.yaml') - overlay = os.path.join(datafiles.dirname, datafiles.basename, filename) + prov_file, prov_line, prov_col, caching): + base_file = os.path.join(datafiles.dirname, datafiles.basename, 'basics.yaml') + overlay_file = os.path.join(datafiles.dirname, datafiles.basename, filename) + + base = load_yaml_file(base_file, cache_path=tmpdir, shortname='basics.yaml', from_cache=caching) + overlay = load_yaml_file(overlay_file, cache_path=tmpdir, shortname=filename, from_cache=caching) - base = _yaml.load(base, shortname='basics.yaml') - overlay = _yaml.load(overlay, shortname=filename) _yaml.composite_dict(base, overlay) children = _yaml.node_get(base, list, 'children') -- GitLab