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.py61
1 files changed, 35 insertions, 26 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 0e806c0ff7..c7a23407c1 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2277,7 +2277,7 @@ class GitLfsTest(FetcherTest):
2277 2277
2278 @skipIfNoGitLFS() 2278 @skipIfNoGitLFS()
2279 @skipIfNoNetwork() 2279 @skipIfNoNetwork()
2280 def test_real_git_lfs_repo_succeeds(self): 2280 def test_real_git_lfs_repo_skips(self):
2281 self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=0") 2281 self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=0")
2282 f = self.get_real_git_lfs_file() 2282 f = self.get_real_git_lfs_file()
2283 # This is the actual non-smudged placeholder file on the repo if git-lfs does not run 2283 # This is the actual non-smudged placeholder file on the repo if git-lfs does not run
@@ -2290,24 +2290,41 @@ class GitLfsTest(FetcherTest):
2290 with open(f) as fh: 2290 with open(f) as fh:
2291 self.assertEqual(lfs_file, fh.read()) 2291 self.assertEqual(lfs_file, fh.read())
2292 2292
2293 @skipIfNoGitLFS()
2293 def test_lfs_enabled(self): 2294 def test_lfs_enabled(self):
2294 import shutil 2295 import shutil
2295 2296
2296 uri = 'git://%s;protocol=file;lfs=1;branch=master' % self.srcdir 2297 uri = 'git://%s;protocol=file;lfs=1;branch=master' % self.srcdir
2297 self.d.setVar('SRC_URI', uri) 2298 self.d.setVar('SRC_URI', uri)
2298 2299
2299 # Careful: suppress initial attempt at downloading until 2300 # With git-lfs installed, test that we can fetch and unpack
2300 # we know whether git-lfs is installed. 2301 fetcher, ud = self.fetch()
2301 fetcher, ud = self.fetch(uri=None, download=False) 2302 shutil.rmtree(self.gitdir, ignore_errors=True)
2302 self.assertIsNotNone(ud.method._find_git_lfs) 2303 fetcher.unpack(self.d.getVar('WORKDIR'))
2303 2304
2304 # If git-lfs can be found, the unpack should be successful. Only 2305 @skipIfNoGitLFS()
2305 # attempt this with the real live copy of git-lfs installed. 2306 def test_lfs_disabled(self):
2306 if ud.method._find_git_lfs(self.d): 2307 import shutil
2307 fetcher.download() 2308
2308 shutil.rmtree(self.gitdir, ignore_errors=True) 2309 uri = 'git://%s;protocol=file;lfs=0;branch=master' % self.srcdir
2309 fetcher.unpack(self.d.getVar('WORKDIR')) 2310 self.d.setVar('SRC_URI', uri)
2310 2311
2312 # Verify that the fetcher can survive even if the source
2313 # repository has Git LFS usage configured.
2314 fetcher, ud = self.fetch()
2315 fetcher.unpack(self.d.getVar('WORKDIR'))
2316
2317 def test_lfs_enabled_not_installed(self):
2318 import shutil
2319
2320 uri = 'git://%s;protocol=file;lfs=1;branch=master' % self.srcdir
2321 self.d.setVar('SRC_URI', uri)
2322
2323 # Careful: suppress initial attempt at downloading
2324 fetcher, ud = self.fetch(uri=None, download=False)
2325
2326 # Artificially assert that git-lfs is not installed, so
2327 # we can verify a failure to unpack in it's absence.
2311 old_find_git_lfs = ud.method._find_git_lfs 2328 old_find_git_lfs = ud.method._find_git_lfs
2312 try: 2329 try:
2313 # If git-lfs cannot be found, the unpack should throw an error 2330 # If git-lfs cannot be found, the unpack should throw an error
@@ -2319,29 +2336,21 @@ class GitLfsTest(FetcherTest):
2319 finally: 2336 finally:
2320 ud.method._find_git_lfs = old_find_git_lfs 2337 ud.method._find_git_lfs = old_find_git_lfs
2321 2338
2322 def test_lfs_disabled(self): 2339 def test_lfs_disabled_not_installed(self):
2323 import shutil 2340 import shutil
2324 2341
2325 uri = 'git://%s;protocol=file;lfs=0;branch=master' % self.srcdir 2342 uri = 'git://%s;protocol=file;lfs=0;branch=master' % self.srcdir
2326 self.d.setVar('SRC_URI', uri) 2343 self.d.setVar('SRC_URI', uri)
2327 2344
2328 # In contrast to test_lfs_enabled(), allow the implicit download 2345 # Careful: suppress initial attempt at downloading
2329 # done by self.fetch() to occur here. The point of this test case 2346 fetcher, ud = self.fetch(uri=None, download=False)
2330 # is to verify that the fetcher can survive even if the source
2331 # repository has Git LFS usage configured.
2332 fetcher, ud = self.fetch()
2333 self.assertIsNotNone(ud.method._find_git_lfs)
2334 2347
2348 # Artificially assert that git-lfs is not installed, so
2349 # we can verify a failure to unpack in it's absence.
2335 old_find_git_lfs = ud.method._find_git_lfs 2350 old_find_git_lfs = ud.method._find_git_lfs
2336 try: 2351 try:
2337 # If git-lfs can be found, the unpack should be successful. A 2352 # Even if git-lfs cannot be found, the unpack should be successful
2338 # live copy of git-lfs is not required for this case, so 2353 fetcher.download()
2339 # unconditionally forge its presence.
2340 ud.method._find_git_lfs = lambda d: True
2341 shutil.rmtree(self.gitdir, ignore_errors=True)
2342 fetcher.unpack(self.d.getVar('WORKDIR'))
2343 # If git-lfs cannot be found, the unpack should be successful
2344
2345 ud.method._find_git_lfs = lambda d: False 2354 ud.method._find_git_lfs = lambda d: False
2346 shutil.rmtree(self.gitdir, ignore_errors=True) 2355 shutil.rmtree(self.gitdir, ignore_errors=True)
2347 fetcher.unpack(self.d.getVar('WORKDIR')) 2356 fetcher.unpack(self.d.getVar('WORKDIR'))