diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-10-22 21:12:10 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-10-22 21:12:10 +0000 |
commit | c5c29c99662d1bc667bcbd41c6d2f288b6c0e57d (patch) | |
tree | 669d35b74602826aabc9da870adf4d5ee64cdf56 | |
parent | 422718fbf655e13c563f5a70a7db4d029a414f51 (diff) | |
parent | 349c38905faf64cfa71294bded4cb6dc13d61723 (diff) | |
download | buildstream-c5c29c99662d1bc667bcbd41c6d2f288b6c0e57d.tar.gz |
Merge branch 'chandan/fix-source-key-test' into 'master'
tests/sources/keytest: Ensure element state is updated as expected
Closes #1179
See merge request BuildStream/buildstream!1664
-rw-r--r-- | tests/sources/keytest.py | 3 | ||||
-rw-r--r-- | tests/sources/project_key_test/plugins/sources/key-test.py | 18 |
2 files changed, 12 insertions, 9 deletions
diff --git a/tests/sources/keytest.py b/tests/sources/keytest.py index dbfe97ab5..5b5ccaba0 100644 --- a/tests/sources/keytest.py +++ b/tests/sources/keytest.py @@ -41,8 +41,11 @@ def test_generate_key(cli, datafiles): res = cli.run(project=project_dir, args=["build", "key-test.bst"]) res.assert_main_error(ErrorDomain.PIPELINE, "inconsistent-pipeline") + assert cli.get_element_state(project_dir, "key-test.bst") == "no reference" res = cli.run(project=project_dir, args=["source", "track", "key-test.bst"]) res.assert_success() + assert cli.get_element_state(project_dir, "key-test.bst") == "fetch needed" res = cli.run(project=project_dir, args=["build", "--track", "key-test.bst"]) res.assert_success() + assert cli.get_element_state(project_dir, "key-test.bst") == "cached" diff --git a/tests/sources/project_key_test/plugins/sources/key-test.py b/tests/sources/project_key_test/plugins/sources/key-test.py index 9331ba094..428846a3e 100644 --- a/tests/sources/project_key_test/plugins/sources/key-test.py +++ b/tests/sources/project_key_test/plugins/sources/key-test.py @@ -1,3 +1,5 @@ +import os + from buildstream import Source, Consistency @@ -5,15 +7,11 @@ class KeyTest(Source): """ This plugin should fail if get_unique_key is called before track """ - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.ref = False - def preflight(self): pass def configure(self, node): - pass + self.ref = node.get_bool("ref", False) def get_unique_key(self): assert self.ref @@ -29,19 +27,21 @@ class KeyTest(Source): pass def get_ref(self): - pass + return self.ref def set_ref(self, ref, node): - pass + node["ref"] = self.ref = ref def track(self, **kwargs): - self.ref = True + return True def fetch(self, **kwargs): pass def stage(self, directory): - pass + # Create a dummy file as output, as import elements do not allow empty + # output. Its existence is a statement that we have staged ourselves. + open(os.path.join(directory, "output"), "w").close() def setup(): |