aboutsummaryrefslogtreecommitdiffstats
path: root/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:27 +0000
commit9e913ade70474aaeb928814d4763e7105569d63a (patch)
tree88ed4e6c8a9f375e9c768decaf0b754ad0f2ac05 /lib/bb/tests/fetch.py
parenta3a3a40b96c29051d97d0c96eb01784cbd1f5420 (diff)
downloadbitbake-9e913ade70474aaeb928814d4763e7105569d63a.tar.gz
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. Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/tests/fetch.py')
-rw-r--r--lib/bb/tests/fetch.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 16a1b6f34..9fb6378fd 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -2322,15 +2322,24 @@ class NPMTest(FetcherTest):
ud = fetcher.ud[fetcher.urls[0]]
fetcher.download()
self.assertTrue(os.path.exists(ud.localpath))
- # Setup the mirror
- pkgname = os.path.basename(ud.proxy.urls[0].split(';')[0])
+
+ # Setup the mirror by renaming the download directory
mirrordir = os.path.join(self.tempdir, 'mirror')
- bb.utils.mkdirhier(mirrordir)
- os.replace(ud.localpath, os.path.join(mirrordir, pkgname))
- self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/' % mirrordir)
+ bb.utils.rename(self.dldir, mirrordir)
+ os.mkdir(self.dldir)
+
+ # Configure the premirror to be used
+ self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/npm2' % mirrordir)
self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
+
# Fetch again
self.assertFalse(os.path.exists(ud.localpath))
+ # The npm fetcher doesn't handle that the .resolved file disappears
+ # while the fetcher object exists, which it does when we rename the
+ # download directory to "mirror" above. Thus we need a new fetcher to go
+ # with the now empty download directory.
+ fetcher = bb.fetch.Fetch([url], self.d)
+ ud = fetcher.ud[fetcher.urls[0]]
fetcher.download()
self.assertTrue(os.path.exists(ud.localpath))