diff options
-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(): |