diff options
author | Pavel Zhukov <pavel@zhukoff.net> | 2023-01-17 16:36:43 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-18 16:42:27 +0000 |
commit | 2ac1235b9b6b14644c6bd6ff820264ed49d70170 (patch) | |
tree | cdafd002cd9af62a03fedba201cfe71a32dd342c /bitbake | |
parent | e82805663f9c8976617006edfce1e7bcb1bd5c22 (diff) | |
download | poky-2ac1235b9b6b14644c6bd6ff820264ed49d70170.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 44 |
1 files changed, 44 insertions, 0 deletions
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): | |||
2936 | with self.assertRaises(bb.fetch2.NetworkAccess): | 2936 | with self.assertRaises(bb.fetch2.NetworkAccess): |
2937 | fetcher.download() | 2937 | fetcher.download() |
2938 | 2938 | ||
2939 | class FetchPremirroronlyMercurialTest(FetcherTest): | ||
2940 | """ Test for premirrors with mercurial repos | ||
2941 | the test covers also basic hg:// clone (see fetch_and_create_tarball | ||
2942 | """ | ||
2943 | def skipIfNoHg(): | ||
2944 | import shutil | ||
2945 | if not shutil.which('hg'): | ||
2946 | return unittest.skip('Mercurial not installed') | ||
2947 | return lambda f: f | ||
2948 | |||
2949 | def setUp(self): | ||
2950 | super(FetchPremirroronlyMercurialTest, self).setUp() | ||
2951 | self.mirrordir = os.path.join(self.tempdir, "mirrors") | ||
2952 | os.mkdir(self.mirrordir) | ||
2953 | self.reponame = "libgnt" | ||
2954 | self.clonedir = os.path.join(self.tempdir, "hg") | ||
2955 | self.recipe_url = "hg://keep.imfreedom.org/libgnt;module=libgnt" | ||
2956 | self.d.setVar("SRCREV", "53e8b422faaf") | ||
2957 | self.mirrorname = "hg_libgnt_keep.imfreedom.org_.libgnt.tar.gz" | ||
2958 | |||
2959 | def fetch_and_create_tarball(self): | ||
2960 | """ | ||
2961 | Ask bitbake to download repo and prepare mirror tarball for us | ||
2962 | """ | ||
2963 | self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "1") | ||
2964 | fetcher = bb.fetch.Fetch([self.recipe_url], self.d) | ||
2965 | fetcher.download() | ||
2966 | mirrorfile = os.path.join(self.d.getVar("DL_DIR"), self.mirrorname) | ||
2967 | self.assertTrue(os.path.exists(mirrorfile), "Mirror tarball {} has not been created".format(mirrorfile)) | ||
2968 | ## moving tarball to mirror directory | ||
2969 | os.rename(mirrorfile, os.path.join(self.mirrordir, self.mirrorname)) | ||
2970 | self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "0") | ||
2971 | |||
2972 | |||
2973 | @skipIfNoNetwork() | ||
2974 | @skipIfNoHg() | ||
2975 | def test_premirror_mercurial(self): | ||
2976 | self.fetch_and_create_tarball() | ||
2977 | self.d.setVar("PREMIRRORS", self.recipe_url + " " + "file://{}".format(self.mirrordir) + " \n") | ||
2978 | self.d.setVar("BB_FETCH_PREMIRRORONLY", "1") | ||
2979 | self.d.setVar("BB_NO_NETWORK", "1") | ||
2980 | fetcher = bb.fetch.Fetch([self.recipe_url], self.d) | ||
2981 | fetcher.download() | ||
2982 | |||
2939 | class FetchPremirroronlyBrokenTarball(FetcherTest): | 2983 | class FetchPremirroronlyBrokenTarball(FetcherTest): |
2940 | 2984 | ||
2941 | def setUp(self): | 2985 | def setUp(self): |