summaryrefslogtreecommitdiff
path: root/tests/sources
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2019-10-22 15:37:33 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-10-22 20:26:39 +0000
commit349c38905faf64cfa71294bded4cb6dc13d61723 (patch)
tree669d35b74602826aabc9da870adf4d5ee64cdf56 /tests/sources
parent422718fbf655e13c563f5a70a7db4d029a414f51 (diff)
downloadbuildstream-349c38905faf64cfa71294bded4cb6dc13d61723.tar.gz
tests/sources/keytest: Ensure element state is updated as expected
This contains two changes: * tests/sources/keytest.py: Ensure that the element state before/after BuildStream operations is updated as expected. Previously we were just checking that the command succeeded. * tests/sources/project_key_test/plugins/sources/key-test.py: Update the dummy plugin that's used for tests, such that it conforms to the expectations of a BuildStream source class. Fixes #1179.
Diffstat (limited to 'tests/sources')
-rw-r--r--tests/sources/keytest.py3
-rw-r--r--tests/sources/project_key_test/plugins/sources/key-test.py18
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():