Skip to contentSkip to conversation

fetch2: add stub latest_versionstring to FetchMethod

PATCH New Ross Burton 1 participant 2 messages Sep 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 fetch2: add stub latest_versionstring to FetchMethod

---
 bitbake/lib/bb/fetch2/__init__.py | 8 ++++++++
 1 file changed, 8 insertions(+)
bitbake/lib/bb/fetch2/__init__.py +8 -0
index 3eb0e4d2110..f70f1b51575 100644
@@ -1559,6 +1559,14 @@ class FetchMethod(object):
         key = self._revision_key(ud, d, name)
         return "%s-%s" % (key, d.getVar("PN") or "")
 
+    def latest_versionstring(self, ud, d):
+        """
+        Compute the latest release name like "x.y.x" in "x.y.x+gitHASH"
+        by searching through the tags output of ls-remote, comparing
+        versions and returning the highest match as a (version, revision) pair.
+        """
+        return ('', '')
+
 class Fetch(object):
     def __init__(self, urls, d, cache = True, localonly = False, connection_cache = None):
         if localonly and cache:
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/2 tests/fetch: handle network failures gracefully

If there is a network failure the return value from latest_versionstring() is ('','') which later causes an exception when comparing versions.

Improve this by checking the return value and failing the test early.

[ YOCTO #12053 ]

---
 bitbake/lib/bb/tests/fetch.py | 2 ++
 1 file changed, 2 insertions(+)
bitbake/lib/bb/tests/fetch.py +2 -0
index faa5c74aae0..209b13f6953 100644
@@ -793,6 +793,7 @@ class FetchLatestVersionTest(FetcherTest):
                 ud = bb.fetch2.FetchData(k[1], self.d)
                 pupver= ud.method.latest_versionstring(ud, self.d)
                 verstring = pupver[0]
+                self.assertTrue(verstring, msg="Could not find upstream version")
                 r = bb.utils.vercmp_string(v, verstring)
                 self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring))
 
@@ -804,6 +805,7 @@ class FetchLatestVersionTest(FetcherTest):
                 ud = bb.fetch2.FetchData(k[1], self.d)
                 pupver = ud.method.latest_versionstring(ud, self.d)
                 verstring = pupver[0]
+                self.assertTrue(verstring, msg="Could not find upstream version")
                 r = bb.utils.vercmp_string(v, verstring)
                 self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring))
 
Signature · 1 line
2.11.0