From 551fdabc54f34b6ffa940dfd616b44ef4858277d Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Fri, 19 Apr 2024 14:17:13 +0200 Subject: bitbake: fetch2/crate: add upstream latest version check function This is actually rather easy: crate web API provides a json with all the versions, for example: https://crates.io/api/v1/crates/cargo-c/versions (Bitbake rev: f6c2755db9a1f88c8534193b420fa31d135945e6) Signed-off-by: Alexander Kanavin Signed-off-by: Richard Purdie --- bitbake/lib/bb/tests/fetch.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'bitbake/lib/bb/tests') diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 85c1f79ff3..e5d85f9dac 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py @@ -1493,6 +1493,12 @@ class FetchLatestVersionTest(FetcherTest): : "2.8", } + test_crate_uris = { + # basic example; version pattern "A.B.C+cargo-D.E.F" + ("cargo-c", "crate://crates.io/cargo-c/0.9.18+cargo-0.69") + : "0.9.29" + } + @skipIfNoNetwork() def test_git_latest_versionstring(self): for k, v in self.test_git_uris.items(): @@ -1532,6 +1538,16 @@ class FetchLatestVersionTest(FetcherTest): finally: server.stop() + @skipIfNoNetwork() + def test_crate_latest_versionstring(self): + for k, v in self.test_crate_uris.items(): + self.d.setVar("PN", k[0]) + 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 for %s" % k[0]) + r = bb.utils.vercmp_string(v, verstring) + self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring)) class FetchCheckStatusTest(FetcherTest): test_wget_uris = ["https://downloads.yoctoproject.org/releases/sato/sato-engine-0.1.tar.gz", -- cgit v1.2.3-54-g00ecf