From f1745ce249da7b862e1976bbeda45ac7d781efd2 Mon Sep 17 00:00:00 2001 From: Stefan Herbrechtsmeier Date: Mon, 9 Dec 2024 11:31:58 +0100 Subject: [PATCH] bitbake: tests: fetch: add npmsw test case for bundled dependencies The npm package lock and shrinkwrap file list bundled dependencies which are supplied together with the parent dependency. The bundled dependencies are marked by a flag. The flag and thereby test depends on the lock file version. The old lock file version uses a `bundled` flag and stores dependencies in the `dependencies` list. The new lock file version uses an `inBundle` flag and stores dependencies in the `packages` list. (Bitbake rev: 34fd8ea6abe755e04220fe70b082aa620ae15f86) Signed-off-by: Stefan Herbrechtsmeier Signed-off-by: Richard Purdie --- bitbake/lib/bb/tests/fetch.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 3eaaa83620..6dda0d3813 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py @@ -3112,6 +3112,32 @@ class NPMTest(FetcherTest): fetcher.download() self.assertTrue(os.path.exists(ud.localpath)) + @skipIfNoNetwork() + def test_npmsw_bundled(self): + for packages_key, package_prefix, bundled_key in [ + ('dependencies', '', 'bundled'), + ('packages', 'node_modules/', 'inBundle') + ]: + swfile = self.create_shrinkwrap_file({ + packages_key: { + package_prefix + 'array-flatten': { + 'version': '1.1.1', + 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', + 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' + }, + package_prefix + 'content-type': { + 'version': '1.0.4', + 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz', + 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==', + bundled_key: True + } + } + }) + fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) + fetcher.download() + self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz'))) + self.assertFalse(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz'))) + class GitSharedTest(FetcherTest): def setUp(self): super(GitSharedTest, self).setUp()