mirror of
https://git.yoctoproject.org/poky
synced 2026-04-04 23:02:22 +02:00
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 <weaverjs@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
3b58b1fc1c
commit
7de1e4cd7a
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user