diff options
author | Benjamin Schubert <bschubert15@bloomberg.net> | 2019-11-28 10:59:52 +0000 |
---|---|---|
committer | Benjamin Schubert <bschubert15@bloomberg.net> | 2020-01-16 16:33:19 +0000 |
commit | 3be6d07753599ef54b9e80ac066571632e217ce2 (patch) | |
tree | e14db9bba2d32ddb2840ab5513afde5b1ece2055 /tests/frontend | |
parent | 4a47af24fca8aeb6c0c0fe6bd754712ecce5211d (diff) | |
download | buildstream-3be6d07753599ef54b9e80ac066571632e217ce2.tar.gz |
source.py: Remove the reliance on consistency to get whether a source is cached
This removes the need to use consistency in Sources, by asking
explicitely whether the source is cached or not.
This introduces a new public method on source: `is_cached` that needs
implementation and that should return whether the source has a local
copy or not.
- On fetch, also reset whether the source was cached or set if as
cached when we know it was.
- Validate the cache's source after fetching it
This doesn't need to be run in the scheduler's process and can be
offloaded to the child, which will allow better multiprocessing
Diffstat (limited to 'tests/frontend')
5 files changed, 11 insertions, 2 deletions
diff --git a/tests/frontend/consistencyerror/bug.bst b/tests/frontend/consistencyerror/bug.bst index a66002046..5639abee2 100644 --- a/tests/frontend/consistencyerror/bug.bst +++ b/tests/frontend/consistencyerror/bug.bst @@ -1,4 +1,4 @@ kind: import -description: An element with an unhandled exception at get_consistency time +description: An element with an unhandled exception in checking whether it is cached or not sources: - kind: consistencybug diff --git a/tests/frontend/consistencyerror/error.bst b/tests/frontend/consistencyerror/error.bst index ccf11c942..e377aa97a 100644 --- a/tests/frontend/consistencyerror/error.bst +++ b/tests/frontend/consistencyerror/error.bst @@ -1,4 +1,4 @@ kind: import -description: An element with a failing source at get_consistency time +description: An element with a failing source when checking whether it is cached or not sources: - kind: consistencyerror diff --git a/tests/frontend/consistencyerror/plugins/consistencybug.py b/tests/frontend/consistencyerror/plugins/consistencybug.py index c4a3217ec..7f0bd9211 100644 --- a/tests/frontend/consistencyerror/plugins/consistencybug.py +++ b/tests/frontend/consistencyerror/plugins/consistencybug.py @@ -14,6 +14,9 @@ class ConsistencyBugSource(Source): def is_resolved(self): return True + def is_cached(self): + return True + def get_consistency(self): # Raise an unhandled exception (not a BstError) diff --git a/tests/frontend/consistencyerror/plugins/consistencyerror.py b/tests/frontend/consistencyerror/plugins/consistencyerror.py index d7433e368..523ac0b6f 100644 --- a/tests/frontend/consistencyerror/plugins/consistencyerror.py +++ b/tests/frontend/consistencyerror/plugins/consistencyerror.py @@ -14,6 +14,9 @@ class ConsistencyErrorSource(Source): def is_resolved(self): return True + def is_cached(self): + return True + def get_consistency(self): # Raise an error unconditionally diff --git a/tests/frontend/project/sources/fetch_source.py b/tests/frontend/project/sources/fetch_source.py index d634adfa3..60b4ba95d 100644 --- a/tests/frontend/project/sources/fetch_source.py +++ b/tests/frontend/project/sources/fetch_source.py @@ -69,6 +69,9 @@ class FetchSource(Source): def is_resolved(self): return True + def is_cached(self) -> bool: + return self.get_consistency() == Consistency.CACHED + def get_consistency(self): if not os.path.exists(self.output_file): return Consistency.RESOLVED |