diff options
author | Benjamin Schubert <bschubert15@bloomberg.net> | 2019-11-27 16:26:37 +0000 |
---|---|---|
committer | Benjamin Schubert <bschubert15@bloomberg.net> | 2020-01-16 16:33:19 +0000 |
commit | 4a47af24fca8aeb6c0c0fe6bd754712ecce5211d (patch) | |
tree | 08f72ea7bbc2979637900b1bcaeb8aa798d41c52 /tests/sources | |
parent | 93ebe4992c32b2588ae213a98c3e05d60c974a00 (diff) | |
download | buildstream-4a47af24fca8aeb6c0c0fe6bd754712ecce5211d.tar.gz |
source.py: Add a new 'is_resolved' to get whether a source is resolved.
`get_consistency` is coarse grained and hard to optimize, in addition
to being un-userfriendly.
This adds a new `is_resolved` that has for default implementation
`get_ref() is not None`, which is true for most sources in BuildStream.
Sources for which this is not true can override the method to give a
more accurate description.
Checking for this before looking whether the source is cached can
reduce the amount of work necessary in some pipeline and opens the
door for more optimizations and the removal of the source state check.
Diffstat (limited to 'tests/sources')
-rw-r--r-- | tests/sources/no-fetch-cached/plugins/sources/always_cached.py | 3 | ||||
-rw-r--r-- | tests/sources/project_key_test/plugins/sources/key-test.py | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/tests/sources/no-fetch-cached/plugins/sources/always_cached.py b/tests/sources/no-fetch-cached/plugins/sources/always_cached.py index 623ab19ab..5f05b592b 100644 --- a/tests/sources/no-fetch-cached/plugins/sources/always_cached.py +++ b/tests/sources/no-fetch-cached/plugins/sources/always_cached.py @@ -20,6 +20,9 @@ class AlwaysCachedSource(Source): def get_unique_key(self): return None + def is_resolved(self): + return True + def get_consistency(self): return Consistency.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 428846a3e..30256929c 100644 --- a/tests/sources/project_key_test/plugins/sources/key-test.py +++ b/tests/sources/project_key_test/plugins/sources/key-test.py @@ -11,7 +11,10 @@ class KeyTest(Source): pass def configure(self, node): - self.ref = node.get_bool("ref", False) + if node.get_scalar("ref", None).is_none(): + self.ref = None + else: + self.ref = True def get_unique_key(self): assert self.ref |