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.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 4702c99a7e..9453c90d2b 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2046,13 +2046,14 @@ class GitLfsTest(FetcherTest):
2046 cwd = self.gitdir 2046 cwd = self.gitdir
2047 return bb.process.run(cmd, cwd=cwd)[0] 2047 return bb.process.run(cmd, cwd=cwd)[0]
2048 2048
2049 def fetch(self, uri=None): 2049 def fetch(self, uri=None, download=True):
2050 uris = self.d.getVar('SRC_URI').split() 2050 uris = self.d.getVar('SRC_URI').split()
2051 uri = uris[0] 2051 uri = uris[0]
2052 d = self.d 2052 d = self.d
2053 2053
2054 fetcher = bb.fetch2.Fetch(uris, d) 2054 fetcher = bb.fetch2.Fetch(uris, d)
2055 fetcher.download() 2055 if download:
2056 fetcher.download()
2056 ud = fetcher.ud[uri] 2057 ud = fetcher.ud[uri]
2057 return fetcher, ud 2058 return fetcher, ud
2058 2059
@@ -2062,16 +2063,21 @@ class GitLfsTest(FetcherTest):
2062 uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir 2063 uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir
2063 self.d.setVar('SRC_URI', uri) 2064 self.d.setVar('SRC_URI', uri)
2064 2065
2065 fetcher, ud = self.fetch() 2066 # Careful: suppress initial attempt at downloading until
2067 # we know whether git-lfs is installed.
2068 fetcher, ud = self.fetch(uri=None, download=False)
2066 self.assertIsNotNone(ud.method._find_git_lfs) 2069 self.assertIsNotNone(ud.method._find_git_lfs)
2067 2070
2068 # If git-lfs can be found, the unpack should be successful 2071 # If git-lfs can be found, the unpack should be successful. Only
2069 ud.method._find_git_lfs = lambda d: True 2072 # attempt this with the real live copy of git-lfs installed.
2070 shutil.rmtree(self.gitdir, ignore_errors=True) 2073 if ud.method._find_git_lfs(self.d):
2071 fetcher.unpack(self.d.getVar('WORKDIR')) 2074 fetcher.download()
2075 shutil.rmtree(self.gitdir, ignore_errors=True)
2076 fetcher.unpack(self.d.getVar('WORKDIR'))
2072 2077
2073 # If git-lfs cannot be found, the unpack should throw an error 2078 # If git-lfs cannot be found, the unpack should throw an error
2074 with self.assertRaises(bb.fetch2.FetchError): 2079 with self.assertRaises(bb.fetch2.FetchError):
2080 fetcher.download()
2075 ud.method._find_git_lfs = lambda d: False 2081 ud.method._find_git_lfs = lambda d: False
2076 shutil.rmtree(self.gitdir, ignore_errors=True) 2082 shutil.rmtree(self.gitdir, ignore_errors=True)
2077 fetcher.unpack(self.d.getVar('WORKDIR')) 2083 fetcher.unpack(self.d.getVar('WORKDIR'))
@@ -2082,10 +2088,16 @@ class GitLfsTest(FetcherTest):
2082 uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir 2088 uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir
2083 self.d.setVar('SRC_URI', uri) 2089 self.d.setVar('SRC_URI', uri)
2084 2090
2091 # In contrast to test_lfs_enabled(), allow the implicit download
2092 # done by self.fetch() to occur here. The point of this test case
2093 # is to verify that the fetcher can survive even if the source
2094 # repository has Git LFS usage configured.
2085 fetcher, ud = self.fetch() 2095 fetcher, ud = self.fetch()
2086 self.assertIsNotNone(ud.method._find_git_lfs) 2096 self.assertIsNotNone(ud.method._find_git_lfs)
2087 2097
2088 # If git-lfs can be found, the unpack should be successful 2098 # If git-lfs can be found, the unpack should be successful. A
2099 # live copy of git-lfs is not required for this case, so
2100 # unconditionally forge its presence.
2089 ud.method._find_git_lfs = lambda d: True 2101 ud.method._find_git_lfs = lambda d: True
2090 shutil.rmtree(self.gitdir, ignore_errors=True) 2102 shutil.rmtree(self.gitdir, ignore_errors=True)
2091 fetcher.unpack(self.d.getVar('WORKDIR')) 2103 fetcher.unpack(self.d.getVar('WORKDIR'))