diff options
Diffstat (limited to 'buildstream/_pipeline.py')
-rw-r--r-- | buildstream/_pipeline.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index a9645aed9..1dd4ec815 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -383,6 +383,33 @@ class Pipeline(): detail += " " + element._get_full_name() + "\n" raise PipelineError("Inconsistent pipeline", detail=detail, reason="inconsistent-pipeline-workspaced") + # assert_sources_cached() + # + # Asserts that sources for the given list of elements are cached. + # + # Args: + # elements (list): The list of elements + # + def assert_sources_cached(self, elements): + uncached = [] + with self._context.timed_activity("Checking sources"): + for element in elements: + if element._get_consistency() != Consistency.CACHED: + uncached.append(element) + + if uncached: + detail = "Sources are not cached for the following elements:\n\n" + for element in uncached: + detail += " Following sources for element: {} are not cached:\n".format(element._get_full_name()) + for source in element.sources(): + if source._get_consistency() != Consistency.CACHED: + detail += " {}\n".format(source) + detail += '\n' + detail += "Try fetching these elements first with `bst fetch`,\n" + \ + "or run this command with `--fetch` option\n" + + raise PipelineError("Uncached sources", detail=detail, reason="uncached-sources") + ############################################################# # Private Methods # ############################################################# |