summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2022-01-29 03:29:37 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-05 17:46:44 +0000
commit84963eb74ad8001b8a8961739339422c8411d79b (patch)
tree03ef4b92f515802e84c17782d84166f12ec57285 /bitbake/lib/bb/tests/fetch.py
parentd715e9105feba44116c42620919b32714bb14d2f (diff)
downloadpoky-84963eb74ad8001b8a8961739339422c8411d79b.tar.gz
bitbake: tests/fetch: Make test_npm_premirrors work with the current fetcher
There are two totally opposite use cases for how a premirror is expected to behave in combination with specifying a downloadfilename= parameter in the SRC_URI. On the one hand there is the expectation that it works like any other mirror, which means the premirror is expected to contain a file with the original name specified in the SRC_URI. On the other hand there is the expectation that one can use the artefacts downloaded by bitbake in ${DL_DIR} as a premirror, in which case it is expected to contain a file with the name from the downloadfilename= parameter. The latter case has been how downloaded files have been handled until commit 8a3ff9f3 (fetch2: fix premirror URI when downloadfilename defined), where the fetcher was changed to store files as per the first case. This is also when the test_npm_premirrors test case was modified in commit 5ba191a0 (tests/fetch: add and fix npm tests) to expect the first case. The above change was later reverted in commit 96c30007 (fetch2: fix downloadfilename issue with premirror). However the test_npm_premirrors test case was not updated to match, and has been failing ever since. This has probably gone unnoticed because the npm related test cases require that npm is installed on the host. This commit updates test_npm_premirrors to expect that premirrors use the filenames specified by downloadfilename= as this matches the current fetcher implementation and also is the most likely use case for premirrors. It also tries to mimic how one typically might setup the premirror directory by simply copying the download directory. (Bitbake rev: 9e913ade70474aaeb928814d4763e7105569d63a) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.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.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 16a1b6f342..9fb6378fdc 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2322,15 +2322,24 @@ class NPMTest(FetcherTest):
2322 ud = fetcher.ud[fetcher.urls[0]] 2322 ud = fetcher.ud[fetcher.urls[0]]
2323 fetcher.download() 2323 fetcher.download()
2324 self.assertTrue(os.path.exists(ud.localpath)) 2324 self.assertTrue(os.path.exists(ud.localpath))
2325 # Setup the mirror 2325
2326 pkgname = os.path.basename(ud.proxy.urls[0].split(';')[0]) 2326 # Setup the mirror by renaming the download directory
2327 mirrordir = os.path.join(self.tempdir, 'mirror') 2327 mirrordir = os.path.join(self.tempdir, 'mirror')
2328 bb.utils.mkdirhier(mirrordir) 2328 bb.utils.rename(self.dldir, mirrordir)
2329 os.replace(ud.localpath, os.path.join(mirrordir, pkgname)) 2329 os.mkdir(self.dldir)
2330 self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/' % mirrordir) 2330
2331 # Configure the premirror to be used
2332 self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/npm2' % mirrordir)
2331 self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') 2333 self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
2334
2332 # Fetch again 2335 # Fetch again
2333 self.assertFalse(os.path.exists(ud.localpath)) 2336 self.assertFalse(os.path.exists(ud.localpath))
2337 # The npm fetcher doesn't handle that the .resolved file disappears
2338 # while the fetcher object exists, which it does when we rename the
2339 # download directory to "mirror" above. Thus we need a new fetcher to go
2340 # with the now empty download directory.
2341 fetcher = bb.fetch.Fetch([url], self.d)
2342 ud = fetcher.ud[fetcher.urls[0]]
2334 fetcher.download() 2343 fetcher.download()
2335 self.assertTrue(os.path.exists(ud.localpath)) 2344 self.assertTrue(os.path.exists(ud.localpath))
2336 2345