summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-02 17:41:56 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-02 18:37:12 +0900
commit1f9c41476313614aec4f0444f0eef6055cf3cb14 (patch)
treedded059aace75bed66b68170b6c4169bece3f0ec /tests
parent16462e9cd2007ae9e90fd94a7af5ba4c142cf83e (diff)
downloadbuildstream-1f9c41476313614aec4f0444f0eef6055cf3cb14.tar.gz
source.py: Added `primary` argument to URL marking APIs
The Source must now mention whether the marked or translated URL is "primary" or not. Even when a Source may have multiple URLs, the auxilliary URLs are derived from the primary one, not only is this true for git, but it is mandated by our tracking API which assumes there is a primary URL. This adjusts the `git` source and the test `fetch_source.py` source to behave properly and advertize it's primary URL properly. This is a part of #620
Diffstat (limited to 'tests')
-rw-r--r--tests/frontend/project/sources/fetch_source.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/frontend/project/sources/fetch_source.py b/tests/frontend/project/sources/fetch_source.py
index ebd3fe757..10e89960c 100644
--- a/tests/frontend/project/sources/fetch_source.py
+++ b/tests/frontend/project/sources/fetch_source.py
@@ -15,14 +15,17 @@ from buildstream import Source, Consistency, SourceError, SourceFetcher
class FetchFetcher(SourceFetcher):
- def __init__(self, source, url):
+ def __init__(self, source, url, primary=False):
super().__init__()
self.source = source
self.original_url = url
+ self.primary = primary
self.mark_download_url(url)
def fetch(self, alias_override=None):
- url = self.source.translate_url(self.original_url, alias_override=alias_override)
+ url = self.source.translate_url(self.original_url,
+ alias_override=alias_override,
+ primary=self.primary)
with open(self.source.output_file, "a") as f:
success = url in self.source.fetch_succeeds and self.source.fetch_succeeds[url]
message = "Fetch {} {} from {}\n".format(self.original_url,
@@ -37,12 +40,21 @@ class FetchSource(Source):
# Read config to know which URLs to fetch
def configure(self, node):
self.original_urls = self.node_get_member(node, list, 'urls')
- self.fetchers = [FetchFetcher(self, url) for url in self.original_urls]
self.output_file = self.node_get_member(node, str, 'output-text')
self.fetch_succeeds = {}
if 'fetch-succeeds' in node:
self.fetch_succeeds = {x[0]: x[1] for x in self.node_items(node['fetch-succeeds'])}
+ # First URL is the primary one for this test
+ #
+ primary = True
+ self.fetchers = []
+ for url in self.original_urls:
+ self.mark_download_url(url, primary=primary)
+ fetcher = FetchFetcher(self, url, primary=primary)
+ self.fetchers.append(fetcher)
+ primary = False
+
def get_source_fetchers(self):
return self.fetchers