From 7de1e4cd7a183a68212be30b6f4e964a54852f1d Mon Sep 17 00:00:00 2001 From: Scott Weaver Date: Sun, 5 Sep 2021 18:27:38 -0400 Subject: bitbake: bitbake: tests/fetch: add and fix npm tests This adds one new test that verifies the use of a specific filename when defined in PREMIRRORS. bb.tests.fetch.NPMTest: - test_npm_premirrors_with_specified_filename While testing bz#13039, it was found that test_npm_registry_alternate fails with ENOTFOUND. This was corrected by using npmjs's public mirror. The change to fetch2 for bz#13039 highlighted an issue with the test_npm_premirrors test where the created file:// mirror was using the downloadfilename rather than the tarball that is defined by the npm url. (Bitbake rev: 5ba191a0407af9e652e3b86302dce3e952d6b587) Signed-off-by: Scott Weaver Signed-off-by: Richard Purdie --- bitbake/lib/bb/tests/fetch.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'bitbake/lib/bb/tests') diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 1735d0b071..242be36891 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py @@ -2278,9 +2278,10 @@ class NPMTest(FetcherTest): fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) # Setup the mirror + pkgname = os.path.basename(ud.proxy.urls[0].split(';')[0]) mirrordir = os.path.join(self.tempdir, 'mirror') bb.utils.mkdirhier(mirrordir) - os.replace(ud.localpath, os.path.join(mirrordir, os.path.basename(ud.localpath))) + os.replace(ud.localpath, os.path.join(mirrordir, pkgname)) self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/\n' % mirrordir) self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') # Fetch again @@ -2288,6 +2289,27 @@ class NPMTest(FetcherTest): fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) + @skipIfNoNpm() + @skipIfNoNetwork() + def test_npm_premirrors_with_specified_filename(self): + url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0' + # Fetch once to get a tarball + fetcher = bb.fetch.Fetch([url], self.d) + ud = fetcher.ud[fetcher.urls[0]] + fetcher.download() + self.assertTrue(os.path.exists(ud.localpath)) + # Setup the mirror + mirrordir = os.path.join(self.tempdir, 'mirror') + bb.utils.mkdirhier(mirrordir) + mirrorfilename = os.path.join(mirrordir, os.path.basename(ud.localpath)) + os.replace(ud.localpath, mirrorfilename) + self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s\n' % mirrorfilename) + self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') + # Fetch again + self.assertFalse(os.path.exists(ud.localpath)) + fetcher.download() + self.assertTrue(os.path.exists(ud.localpath)) + @skipIfNoNpm() @skipIfNoNetwork() def test_npm_mirrors(self): @@ -2350,7 +2372,7 @@ class NPMTest(FetcherTest): @skipIfNoNpm() @skipIfNoNetwork() def test_npm_registry_alternate(self): - url = 'npm://registry.freajs.org;package=@savoirfairelinux/node-server-example;version=1.0.0' + url = 'npm://skimdb.npmjs.com;package=@savoirfairelinux/node-server-example;version=1.0.0' fetcher = bb.fetch.Fetch([url], self.d) fetcher.download() fetcher.unpack(self.unpackdir) -- cgit v1.2.3-54-g00ecf