diff options
author | Scott Weaver <weaverjs@gmail.com> | 2021-09-05 18:27:38 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-06 10:19:06 +0100 |
commit | 5ba191a0407af9e652e3b86302dce3e952d6b587 (patch) | |
tree | cb053f11bb5536144ba5f8777202e6dc485e194f | |
parent | 61db3e96530d650e098436fd086f0182d32998f7 (diff) | |
download | bitbake-5ba191a0407af9e652e3b86302dce3e952d6b587.tar.gz |
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.
Signed-off-by: Scott Weaver <weaverjs@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/tests/fetch.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index 1735d0b07..242be3689 100644 --- a/lib/bb/tests/fetch.py +++ b/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 @@ -2290,6 +2291,27 @@ class NPMTest(FetcherTest): @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): # Fetch once to get a tarball url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0' @@ -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) |