summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-02 18:32:54 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-02 18:37:21 +0900
commitf9b2f1a93b8bffb56b4acaf11b77ee30cb79d822 (patch)
treecfc19fda4367efc8365155d6f69038c6650b58fb
parent1f9c41476313614aec4f0444f0eef6055cf3cb14 (diff)
downloadbuildstream-tristan/source-fetcher-changes.tar.gz
source.py: Track marked URLs and assert they are marked during Plugin.configure()tristan/source-fetcher-changes
This cannot test for unaliased URLs, as those can be discovered later on outside of user provided element configuration; at least we assert that if an alias was used, we have seen it at load time. This will cause a BUG to occur for a plugin which marks an aliased URL (or attempts to translate one) outside of `Plugin.configure()`, if that URL was not previously seen. This is a part of #620
-rw-r--r--buildstream/source.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index f9f306904..e6350161f 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -300,6 +300,7 @@ class Source(Plugin):
# The alias_override is only set on a re-instantiated Source
self.__alias_override = alias_override # Tuple of alias and its override to use instead
self.__expected_alias = None # The primary alias
+ self.__marked_urls = set() # Set of marked download URLs
# FIXME: Reconstruct a MetaSource from a Source instead of storing it.
self.__meta = meta # MetaSource stored so we can copy this source later.
@@ -575,6 +576,25 @@ class Source(Plugin):
self.__expected_alias = expected_alias
+ # Enforce proper behaviour of plugins by ensuring that all
+ # aliased URLs have been marked at Plugin.configure() time.
+ #
+ if self._get_configuring():
+ # Record marked urls while configuring
+ #
+ self.__marked_urls.add(url)
+ else:
+ # If an unknown aliased URL is seen after configuring,
+ # this is an error.
+ #
+ # It is still possible that a URL that was not mentioned
+ # in the element configuration can be marked, this is
+ # the case for git submodules which might be automatically
+ # discovered.
+ #
+ assert (url in self.__marked_urls or not _extract_alias(url)), \
+ "URL was not seen at configure time: {}".format(url)
+
def get_project_directory(self):
"""Fetch the project base directory