diff options
author | Darius Makovsky <traveltissues@protonmail.com> | 2019-09-05 14:33:51 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-09-24 15:58:25 +0000 |
commit | b9e2af22bc94d108a27fc9a40f698b4822c7118e (patch) | |
tree | 50206c7e4be6072afc8b51636c0014a47710400d /tests/frontend | |
parent | e25da0391352c596d26fe892f3435c38133c500a (diff) | |
download | buildstream-b9e2af22bc94d108a27fc9a40f698b4822c7118e.tar.gz |
element.py: always check sources for caching
Check that sources are cached even if they are workspaced and do not
reset workspace cache data
partially reverts !1470
closes #1088
element.py: remove workspaces in cache key calc
Using the workspace source plugin, workspaces should now be handled like
sources for the purpose of calculating element cache keys.
partially reverts !1470
works towards #1073
Since the source keys are now calculated using the unique keys of the
workspace source, this change will break external tracking for open
workspaces. In future attempting to track an open workspace might raise
a SourceError. The test is rewritten to close the workspace before
tracking.
Diffstat (limited to 'tests/frontend')
-rw-r--r-- | tests/frontend/workspace.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index a21538325..a49762cae 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -1142,6 +1142,9 @@ def test_external_push_pull(cli, datafiles, tmpdir_factory, guess_element): result.assert_success() +# Attempting to track in an open workspace is not a sensible thing and it's not compatible with workspaces as plugin +# sources: The new ref (if it differed from the old) would have been ignored regardless. +# The user should be expected to simply close the workspace before tracking. @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"]) def test_external_track(cli, datafiles, tmpdir_factory, guess_element): @@ -1151,17 +1154,31 @@ def test_external_track(cli, datafiles, tmpdir_factory, guess_element): arg_elm = [element_name] if not guess_element else [] # Delete the ref from the source so that we can detect if the - # element has been tracked + # element has been tracked after closing the workspace element_contents = _yaml.load(element_file) + ref1 = element_contents.get_sequence('sources').mapping_at(0).get_str('ref') del element_contents.get_sequence('sources').mapping_at(0)['ref'] _yaml.roundtrip_dump(element_contents, element_file) result = cli.run(project=project, args=['-C', workspace, 'source', 'track', *arg_elm]) result.assert_success() - # Element is tracked now + # Element is not tracked now element_contents = _yaml.load(element_file) - assert 'ref' in element_contents.get_sequence('sources').mapping_at(0) + assert 'ref' not in element_contents.get_sequence('sources').mapping_at(0) + + # close the workspace + result = cli.run(project=project, args=['-C', workspace, 'workspace', 'close', *arg_elm]) + result.assert_success() + + # and retrack the element + result = cli.run(project=project, args=['source', 'track', element_name]) + result.assert_success() + + element_contents = _yaml.load(element_file) + ref2 = element_contents.get_sequence('sources').mapping_at(0).get_str('ref') + # these values should be equivalent + assert ref1 == ref2 @pytest.mark.datafiles(DATA_DIR) |