From 2ac1235b9b6b14644c6bd6ff820264ed49d70170 Mon Sep 17 00:00:00 2001 From: Pavel Zhukov Date: Tue, 17 Jan 2023 16:36:43 +0100 Subject: bitbake: fetch2/tests: Add test for Mercurial Basic test for mercurial functionality including PREMIRRORONLY with disabled network (Bitbake rev: c0e349a5fc92e9c90afc53800c7e83495393ff79) Signed-off-by: Pavel Zhukov Signed-off-by: Luca Ceresoli Signed-off-by: Richard Purdie --- bitbake/lib/bb/tests/fetch.py | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'bitbake/lib/bb/tests/fetch.py') diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index ad3d4dea7d..2e5cd14205 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py @@ -2936,6 +2936,50 @@ class FetchPremirroronlyNetworkTest(FetcherTest): with self.assertRaises(bb.fetch2.NetworkAccess): fetcher.download() +class FetchPremirroronlyMercurialTest(FetcherTest): + """ Test for premirrors with mercurial repos + the test covers also basic hg:// clone (see fetch_and_create_tarball + """ + def skipIfNoHg(): + import shutil + if not shutil.which('hg'): + return unittest.skip('Mercurial not installed') + return lambda f: f + + def setUp(self): + super(FetchPremirroronlyMercurialTest, self).setUp() + self.mirrordir = os.path.join(self.tempdir, "mirrors") + os.mkdir(self.mirrordir) + self.reponame = "libgnt" + self.clonedir = os.path.join(self.tempdir, "hg") + self.recipe_url = "hg://keep.imfreedom.org/libgnt;module=libgnt" + self.d.setVar("SRCREV", "53e8b422faaf") + self.mirrorname = "hg_libgnt_keep.imfreedom.org_.libgnt.tar.gz" + + def fetch_and_create_tarball(self): + """ + Ask bitbake to download repo and prepare mirror tarball for us + """ + self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "1") + fetcher = bb.fetch.Fetch([self.recipe_url], self.d) + fetcher.download() + mirrorfile = os.path.join(self.d.getVar("DL_DIR"), self.mirrorname) + self.assertTrue(os.path.exists(mirrorfile), "Mirror tarball {} has not been created".format(mirrorfile)) + ## moving tarball to mirror directory + os.rename(mirrorfile, os.path.join(self.mirrordir, self.mirrorname)) + self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "0") + + + @skipIfNoNetwork() + @skipIfNoHg() + def test_premirror_mercurial(self): + self.fetch_and_create_tarball() + self.d.setVar("PREMIRRORS", self.recipe_url + " " + "file://{}".format(self.mirrordir) + " \n") + self.d.setVar("BB_FETCH_PREMIRRORONLY", "1") + self.d.setVar("BB_NO_NETWORK", "1") + fetcher = bb.fetch.Fetch([self.recipe_url], self.d) + fetcher.download() + class FetchPremirroronlyBrokenTarball(FetcherTest): def setUp(self): -- cgit v1.2.3-54-g00ecf