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-03 15:20:27 +0900
commit51eaa2c38fbeee6a34898bec3db048b0aa108696 (patch)
treefcbafc55e845e7b973f31b062837056642070cfe
parent435dc56ceffcd7ae3824c182a4f4788e07e0b587 (diff)
downloadbuildstream-tristan/source-fetcher-changes-1.2.tar.gz
source.py: Track marked URLs and assert they are marked during Plugin.configure()tristan/source-fetcher-changes-1.2
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 1edabcbf1..f546258e6 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -239,6 +239,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.
@@ -502,6 +503,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