mirror of
https://git.yoctoproject.org/poky
synced 2026-04-27 12:32:13 +02:00
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 <pavel@zhukoff.net> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
e82805663f
commit
2ac1235b9b
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user