summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2025-01-07 10:17:53 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-01-08 11:34:04 +0000
commitc691d4d53f7e4c448e02b9b2c182d8503eb5e067 (patch)
treef3de0c81b5a34c66872fb07cdde2bf30d0dc9f7f /bitbake/lib
parent1f6cda30547a78a5e8c839890fd4f2aacf13bfda (diff)
downloadpoky-c691d4d53f7e4c448e02b9b2c182d8503eb5e067.tar.gz
bitbake: tests: fetch: update npmsw tests to new lockfile format
Update npmsw test cases to new lockfile format. The old lockfile format is required by npm 6 / Node.js 14 which is out of maintenance [2]. [1] https://docs.npmjs.com/cli/v6/configuring-npm/package-lock-json [2] https://nodejs.org/en/about/previous-releases (Bitbake rev: bb59d4fdaf8fb81aa3529e431dcdd4c3d665d742) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/tests/fetch.py135
1 files changed, 54 insertions, 81 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 6dda0d3813..b893482363 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2843,23 +2843,25 @@ class NPMTest(FetcherTest):
2843 @skipIfNoNetwork() 2843 @skipIfNoNetwork()
2844 def test_npmsw(self): 2844 def test_npmsw(self):
2845 swfile = self.create_shrinkwrap_file({ 2845 swfile = self.create_shrinkwrap_file({
2846 'dependencies': { 2846 'packages': {
2847 'array-flatten': { 2847 'node_modules/array-flatten': {
2848 'version': '1.1.1', 2848 'version': '1.1.1',
2849 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 2849 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
2850 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=', 2850 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=',
2851 'dependencies': { 2851 'dependencies': {
2852 'content-type': { 2852 'content-type': "1.0.4"
2853 'version': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz',
2854 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==',
2855 'dependencies': {
2856 'cookie': {
2857 'version': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09',
2858 'from': 'git+https://github.com/jshttp/cookie.git'
2859 }
2860 }
2861 }
2862 } 2853 }
2854 },
2855 'node_modules/array-flatten/node_modules/content-type': {
2856 'version': '1.0.4',
2857 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz',
2858 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==',
2859 'dependencies': {
2860 'cookie': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09'
2861 }
2862 },
2863 'node_modules/array-flatten/node_modules/content-type/node_modules/cookie': {
2864 'resolved': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09'
2863 } 2865 }
2864 } 2866 }
2865 }) 2867 })
@@ -2877,10 +2879,9 @@ class NPMTest(FetcherTest):
2877 @skipIfNoNetwork() 2879 @skipIfNoNetwork()
2878 def test_npmsw_git(self): 2880 def test_npmsw_git(self):
2879 swfile = self.create_shrinkwrap_file({ 2881 swfile = self.create_shrinkwrap_file({
2880 'dependencies': { 2882 'packages': {
2881 'cookie': { 2883 'node_modules/cookie': {
2882 'version': 'github:jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09', 2884 'resolved': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09'
2883 'from': 'github:jshttp/cookie.git'
2884 } 2885 }
2885 } 2886 }
2886 }) 2887 })
@@ -2888,40 +2889,16 @@ class NPMTest(FetcherTest):
2888 fetcher.download() 2889 fetcher.download()
2889 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'github.com.jshttp.cookie.git'))) 2890 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'github.com.jshttp.cookie.git')))
2890 2891
2891 swfile = self.create_shrinkwrap_file({
2892 'dependencies': {
2893 'cookie': {
2894 'version': 'jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09',
2895 'from': 'jshttp/cookie.git'
2896 }
2897 }
2898 })
2899 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2900 fetcher.download()
2901 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'github.com.jshttp.cookie.git')))
2902
2903 swfile = self.create_shrinkwrap_file({
2904 'dependencies': {
2905 'nodejs': {
2906 'version': 'gitlab:gitlab-examples/nodejs.git#892a1f16725e56cc3a2cb0d677be42935c8fc262',
2907 'from': 'gitlab:gitlab-examples/nodejs'
2908 }
2909 }
2910 })
2911 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2912 fetcher.download()
2913 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'gitlab.com.gitlab-examples.nodejs.git')))
2914
2915 @skipIfNoNetwork() 2892 @skipIfNoNetwork()
2916 def test_npmsw_dev(self): 2893 def test_npmsw_dev(self):
2917 swfile = self.create_shrinkwrap_file({ 2894 swfile = self.create_shrinkwrap_file({
2918 'dependencies': { 2895 'packages': {
2919 'array-flatten': { 2896 'node_modules/array-flatten': {
2920 'version': '1.1.1', 2897 'version': '1.1.1',
2921 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 2898 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
2922 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 2899 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
2923 }, 2900 },
2924 'content-type': { 2901 'node_modules/content-type': {
2925 'version': '1.0.4', 2902 'version': '1.0.4',
2926 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz', 2903 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz',
2927 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==', 2904 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==',
@@ -2943,8 +2920,8 @@ class NPMTest(FetcherTest):
2943 @skipIfNoNetwork() 2920 @skipIfNoNetwork()
2944 def test_npmsw_destsuffix(self): 2921 def test_npmsw_destsuffix(self):
2945 swfile = self.create_shrinkwrap_file({ 2922 swfile = self.create_shrinkwrap_file({
2946 'dependencies': { 2923 'packages': {
2947 'array-flatten': { 2924 'node_modules/array-flatten': {
2948 'version': '1.1.1', 2925 'version': '1.1.1',
2949 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 2926 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
2950 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 2927 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
@@ -2958,8 +2935,8 @@ class NPMTest(FetcherTest):
2958 2935
2959 def test_npmsw_no_network_no_tarball(self): 2936 def test_npmsw_no_network_no_tarball(self):
2960 swfile = self.create_shrinkwrap_file({ 2937 swfile = self.create_shrinkwrap_file({
2961 'dependencies': { 2938 'packages': {
2962 'array-flatten': { 2939 'node_modules/array-flatten': {
2963 'version': '1.1.1', 2940 'version': '1.1.1',
2964 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 2941 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
2965 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 2942 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
@@ -2981,8 +2958,8 @@ class NPMTest(FetcherTest):
2981 self.d.setVar('BB_NO_NETWORK', '1') 2958 self.d.setVar('BB_NO_NETWORK', '1')
2982 # Fetch again 2959 # Fetch again
2983 swfile = self.create_shrinkwrap_file({ 2960 swfile = self.create_shrinkwrap_file({
2984 'dependencies': { 2961 'packages': {
2985 'array-flatten': { 2962 'node_modules/array-flatten': {
2986 'version': '1.1.1', 2963 'version': '1.1.1',
2987 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 2964 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
2988 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 2965 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
@@ -2998,8 +2975,8 @@ class NPMTest(FetcherTest):
2998 def test_npmsw_npm_reusability(self): 2975 def test_npmsw_npm_reusability(self):
2999 # Fetch once with npmsw 2976 # Fetch once with npmsw
3000 swfile = self.create_shrinkwrap_file({ 2977 swfile = self.create_shrinkwrap_file({
3001 'dependencies': { 2978 'packages': {
3002 'array-flatten': { 2979 'node_modules/array-flatten': {
3003 'version': '1.1.1', 2980 'version': '1.1.1',
3004 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 2981 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
3005 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 2982 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
@@ -3020,8 +2997,8 @@ class NPMTest(FetcherTest):
3020 def test_npmsw_bad_checksum(self): 2997 def test_npmsw_bad_checksum(self):
3021 # Try to fetch with bad checksum 2998 # Try to fetch with bad checksum
3022 swfile = self.create_shrinkwrap_file({ 2999 swfile = self.create_shrinkwrap_file({
3023 'dependencies': { 3000 'packages': {
3024 'array-flatten': { 3001 'node_modules/array-flatten': {
3025 'version': '1.1.1', 3002 'version': '1.1.1',
3026 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 3003 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
3027 'integrity': 'sha1-gfNEp2hqgLTFKT6P3AsBYMgsBqg=' 3004 'integrity': 'sha1-gfNEp2hqgLTFKT6P3AsBYMgsBqg='
@@ -3033,8 +3010,8 @@ class NPMTest(FetcherTest):
3033 fetcher.download() 3010 fetcher.download()
3034 # Fetch correctly to get a tarball 3011 # Fetch correctly to get a tarball
3035 swfile = self.create_shrinkwrap_file({ 3012 swfile = self.create_shrinkwrap_file({
3036 'dependencies': { 3013 'packages': {
3037 'array-flatten': { 3014 'node_modules/array-flatten': {
3038 'version': '1.1.1', 3015 'version': '1.1.1',
3039 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 3016 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
3040 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 3017 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
@@ -3072,8 +3049,8 @@ class NPMTest(FetcherTest):
3072 # Fetch again 3049 # Fetch again
3073 self.assertFalse(os.path.exists(ud.localpath)) 3050 self.assertFalse(os.path.exists(ud.localpath))
3074 swfile = self.create_shrinkwrap_file({ 3051 swfile = self.create_shrinkwrap_file({
3075 'dependencies': { 3052 'packages': {
3076 'array-flatten': { 3053 'node_modules/array-flatten': {
3077 'version': '1.1.1', 3054 'version': '1.1.1',
3078 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 3055 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
3079 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 3056 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
@@ -3100,8 +3077,8 @@ class NPMTest(FetcherTest):
3100 # Fetch again with invalid url 3077 # Fetch again with invalid url
3101 self.assertFalse(os.path.exists(ud.localpath)) 3078 self.assertFalse(os.path.exists(ud.localpath))
3102 swfile = self.create_shrinkwrap_file({ 3079 swfile = self.create_shrinkwrap_file({
3103 'dependencies': { 3080 'packages': {
3104 'array-flatten': { 3081 'node_modules/array-flatten': {
3105 'version': '1.1.1', 3082 'version': '1.1.1',
3106 'resolved': 'https://invalid', 3083 'resolved': 'https://invalid',
3107 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 3084 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
@@ -3114,29 +3091,25 @@ class NPMTest(FetcherTest):
3114 3091
3115 @skipIfNoNetwork() 3092 @skipIfNoNetwork()
3116 def test_npmsw_bundled(self): 3093 def test_npmsw_bundled(self):
3117 for packages_key, package_prefix, bundled_key in [ 3094 swfile = self.create_shrinkwrap_file({
3118 ('dependencies', '', 'bundled'), 3095 'packages': {
3119 ('packages', 'node_modules/', 'inBundle') 3096 'node_modules/array-flatten': {
3120 ]: 3097 'version': '1.1.1',
3121 swfile = self.create_shrinkwrap_file({ 3098 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz',
3122 packages_key: { 3099 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI='
3123 package_prefix + 'array-flatten': { 3100 },
3124 'version': '1.1.1', 3101 'node_modules/content-type': {
3125 'resolved': 'https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz', 3102 'version': '1.0.4',
3126 'integrity': 'sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=' 3103 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz',
3127 }, 3104 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==',
3128 package_prefix + 'content-type': { 3105 'inBundle': True
3129 'version': '1.0.4',
3130 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz',
3131 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==',
3132 bundled_key: True
3133 }
3134 } 3106 }
3135 }) 3107 }
3136 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) 3108 })
3137 fetcher.download() 3109 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
3138 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz'))) 3110 fetcher.download()
3139 self.assertFalse(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz'))) 3111 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz')))
3112 self.assertFalse(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz')))
3140 3113
3141class GitSharedTest(FetcherTest): 3114class GitSharedTest(FetcherTest):
3142 def setUp(self): 3115 def setUp(self):