summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
authorScott Weaver <weaverjs@gmail.com>2021-09-05 18:27:38 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-07 21:54:39 +0100
commit7de1e4cd7a183a68212be30b6f4e964a54852f1d (patch)
treeee97c66066c727c54e275bb76595bad5f3709d6e /bitbake/lib/bb/tests/fetch.py
parent3b58b1fc1c4d7351029cc24a2dd8f0d776cef00c (diff)
downloadpoky-7de1e4cd7a183a68212be30b6f4e964a54852f1d.tar.gz
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>
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r--bitbake/lib/bb/tests/fetch.py26
1 files changed, 24 insertions, 2 deletions
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):
2278 fetcher.download() 2278 fetcher.download()
2279 self.assertTrue(os.path.exists(ud.localpath)) 2279 self.assertTrue(os.path.exists(ud.localpath))
2280 # Setup the mirror 2280 # Setup the mirror
2281 pkgname = os.path.basename(ud.proxy.urls[0].split(';')[0])
2281 mirrordir = os.path.join(self.tempdir, 'mirror') 2282 mirrordir = os.path.join(self.tempdir, 'mirror')
2282 bb.utils.mkdirhier(mirrordir) 2283 bb.utils.mkdirhier(mirrordir)
2283 os.replace(ud.localpath, os.path.join(mirrordir, os.path.basename(ud.localpath))) 2284 os.replace(ud.localpath, os.path.join(mirrordir, pkgname))
2284 self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/\n' % mirrordir) 2285 self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/\n' % mirrordir)
2285 self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') 2286 self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
2286 # Fetch again 2287 # Fetch again
@@ -2290,6 +2291,27 @@ class NPMTest(FetcherTest):
2290 2291
2291 @skipIfNoNpm() 2292 @skipIfNoNpm()
2292 @skipIfNoNetwork() 2293 @skipIfNoNetwork()
2294 def test_npm_premirrors_with_specified_filename(self):
2295 url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'
2296 # Fetch once to get a tarball
2297 fetcher = bb.fetch.Fetch([url], self.d)
2298 ud = fetcher.ud[fetcher.urls[0]]
2299 fetcher.download()
2300 self.assertTrue(os.path.exists(ud.localpath))
2301 # Setup the mirror
2302 mirrordir = os.path.join(self.tempdir, 'mirror')
2303 bb.utils.mkdirhier(mirrordir)
2304 mirrorfilename = os.path.join(mirrordir, os.path.basename(ud.localpath))
2305 os.replace(ud.localpath, mirrorfilename)
2306 self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s\n' % mirrorfilename)
2307 self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
2308 # Fetch again
2309 self.assertFalse(os.path.exists(ud.localpath))
2310 fetcher.download()
2311 self.assertTrue(os.path.exists(ud.localpath))
2312
2313 @skipIfNoNpm()
2314 @skipIfNoNetwork()
2293 def test_npm_mirrors(self): 2315 def test_npm_mirrors(self):
2294 # Fetch once to get a tarball 2316 # Fetch once to get a tarball
2295 url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0' 2317 url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0'
@@ -2350,7 +2372,7 @@ class NPMTest(FetcherTest):
2350 @skipIfNoNpm() 2372 @skipIfNoNpm()
2351 @skipIfNoNetwork() 2373 @skipIfNoNetwork()
2352 def test_npm_registry_alternate(self): 2374 def test_npm_registry_alternate(self):
2353 url = 'npm://registry.freajs.org;package=@savoirfairelinux/node-server-example;version=1.0.0' 2375 url = 'npm://skimdb.npmjs.com;package=@savoirfairelinux/node-server-example;version=1.0.0'
2354 fetcher = bb.fetch.Fetch([url], self.d) 2376 fetcher = bb.fetch.Fetch([url], self.d)
2355 fetcher.download() 2377 fetcher.download()
2356 fetcher.unpack(self.unpackdir) 2378 fetcher.unpack(self.unpackdir)