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