summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
authorPaulo Neves <paulo@myneves.com>2023-02-17 17:00:38 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-02-22 12:03:39 +0000
commitffcc20770db8c6d5fcf67d8203b43203a4e7226e (patch)
tree790329443eb306354b076fb3ac5eb5c4d15f17b6 /bitbake/lib/bb/tests/fetch.py
parent41c86ad30e2faec6ad286b9131578183b6a17d24 (diff)
downloadpoky-ffcc20770db8c6d5fcf67d8203b43203a4e7226e.tar.gz
bitbake: tests/fetch: Add real git lfs tests and decorator
Added tests that verify that git-lfs works with an actual real git-lfs server. This was not previously the case because the repo in the test was a simulation of git-lfs but not a real git lfs repo. The 2 added tests are almost the same but test that the git lfs file checkout is successfult with or without the lfs=1 flag. The lfs=1 URI parameter is a quirk that triggers 2 different code paths for git lfs. lfs=1, when used on git lfs repositories triggers the git lfs downloading at the fetch bare stage. lfs query parameter unset triggers the git lfs downloading only on checkout as an implicit behavior of git. This leads to possible network access on the unpack stage and outside the DL_DIR. lfs=0 actually disables git-lfs functionality even if supported. (Bitbake rev: d2be7f7f652360f13cd66d0850f3e19ffe2afb0a) Signed-off-by: Paulo Neves <paulo@myneves.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.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 6d16cf59a1..54148b3fdf 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2199,6 +2199,12 @@ class GitShallowTest(FetcherTest):
2199 self.assertIn("fstests.doap", dir) 2199 self.assertIn("fstests.doap", dir)
2200 2200
2201class GitLfsTest(FetcherTest): 2201class GitLfsTest(FetcherTest):
2202 def skipIfNoGitLFS():
2203 import shutil
2204 if not shutil.which('git-lfs'):
2205 return unittest.skip('git-lfs not installed')
2206 return lambda f: f
2207
2202 def setUp(self): 2208 def setUp(self):
2203 FetcherTest.setUp(self) 2209 FetcherTest.setUp(self)
2204 2210
@@ -2232,6 +2238,44 @@ class GitLfsTest(FetcherTest):
2232 ud = fetcher.ud[uri] 2238 ud = fetcher.ud[uri]
2233 return fetcher, ud 2239 return fetcher, ud
2234 2240
2241 def get_real_git_lfs_file(self):
2242 self.d.setVar('PATH', os.environ.get('PATH'))
2243 fetcher, ud = self.fetch()
2244 fetcher.unpack(self.d.getVar('WORKDIR'))
2245 unpacked_lfs_file = os.path.join(self.d.getVar('WORKDIR'), 'git', "Cat_poster_1.jpg")
2246 return unpacked_lfs_file
2247
2248 @skipIfNoGitLFS()
2249 @skipIfNoNetwork()
2250 def test_real_git_lfs_repo_succeeds_without_lfs_param(self):
2251 self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master")
2252 f = self.get_real_git_lfs_file()
2253 self.assertTrue(os.path.exists(f))
2254 self.assertEqual("c0baab607a97839c9a328b4310713307", bb.utils.md5_file(f))
2255
2256 @skipIfNoGitLFS()
2257 @skipIfNoNetwork()
2258 def test_real_git_lfs_repo_succeeds(self):
2259 self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=1")
2260 f = self.get_real_git_lfs_file()
2261 self.assertTrue(os.path.exists(f))
2262 self.assertEqual("c0baab607a97839c9a328b4310713307", bb.utils.md5_file(f))
2263
2264 @skipIfNoGitLFS()
2265 @skipIfNoNetwork()
2266 def test_real_git_lfs_repo_succeeds(self):
2267 self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=0")
2268 f = self.get_real_git_lfs_file()
2269 # This is the actual non-smudged placeholder file on the repo if git-lfs does not run
2270 lfs_file = (
2271 'version https://git-lfs.github.com/spec/v1\n'
2272 'oid sha256:34be66b1a39a1955b46a12588df9d5f6fc1da790e05cf01f3c7422f4bbbdc26b\n'
2273 'size 11423554\n'
2274 )
2275
2276 with open(f) as fh:
2277 self.assertEqual(lfs_file, fh.read())
2278
2235 def test_lfs_enabled(self): 2279 def test_lfs_enabled(self):
2236 import shutil 2280 import shutil
2237 2281