summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLachlan Mackenzie <lachlan.mackenzie@codethink.co.uk>2018-10-12 11:13:21 +0100
committerJonathan Maw <jonathan.maw@codethink.co.uk>2018-10-15 15:54:59 +0000
commit363cfc3909e10f61e1037e8e744a18b9e29e4ac5 (patch)
tree2d25e0454cdfffba2db73daf7b0a75928eefc50f /tests
parent3d58d7c5d9d485228c267de47a193e5923993207 (diff)
downloadbuildstream-363cfc3909e10f61e1037e8e744a18b9e29e4ac5.tar.gz
yamlcache.py: Add YAML cache changed file test
* Test in same style as test_yamlcache_used * Move of project not required so removed
Diffstat (limited to 'tests')
-rw-r--r--tests/frontend/yamlcache.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/frontend/yamlcache.py b/tests/frontend/yamlcache.py
index 0bcc423ec..7b03c70cc 100644
--- a/tests/frontend/yamlcache.py
+++ b/tests/frontend/yamlcache.py
@@ -112,8 +112,31 @@ def test_yamlcache_used(cli, tmpdir, ref_storage, with_junction, move_project):
@pytest.mark.parametrize('ref_storage', ['inline', 'project.refs'])
@pytest.mark.parametrize('with_junction', ['junction', 'no-junction'])
-@pytest.mark.parametrize('move_project', ['move', 'no-move'])
-def test_yamlcache_changed_file(cli, ref_storage, with_junction, move_project):
+def test_yamlcache_changed_file(cli, tmpdir, ref_storage, with_junction):
# i.e. a file is cached, the file is changed, loading the file (with cache) returns new data
# inline and junction can only be changed by opening a workspace
- pass
+ # Generate the project
+ project = generate_project(str(tmpdir), ref_storage, with_junction)
+ if with_junction == 'junction':
+ result = cli.run(project=project, args=['fetch', '--track', 'junction.bst'])
+ result.assert_success()
+
+ # bst show to put it in the cache
+ result = cli.run(project=project, args=['show', 'test.bst'])
+ result.assert_success()
+
+ element_path = os.path.join(project, 'elements', 'test.bst')
+ with with_yamlcache(project) as (yc, prj):
+ # Check that it's in the cache then modify
+ assert yc.is_cached(prj, element_path)
+ with open(element_path, "a") as f:
+ f.write('\nvariables: {modified: True}\n')
+ # Load modified yaml cache file into cache
+ _yaml.load(element_path, copy_tree=False, project=prj, yaml_cache=yc)
+
+ # Show that a variable has been added
+ result = cli.run(project=project, args=['show', '--format', '%{vars}', 'test.bst'])
+ result.assert_success()
+ data = yaml.safe_load(result.output)
+ assert 'modified' in data
+ assert data['modified'] == 'True'