summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
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