diff options
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 20beab3855..7b2dac7b86 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -2108,13 +2108,14 @@ class GitLfsTest(FetcherTest): | |||
2108 | cwd = self.gitdir | 2108 | cwd = self.gitdir |
2109 | return bb.process.run(cmd, cwd=cwd)[0] | 2109 | return bb.process.run(cmd, cwd=cwd)[0] |
2110 | 2110 | ||
2111 | def fetch(self, uri=None): | 2111 | def fetch(self, uri=None, download=True): |
2112 | uris = self.d.getVar('SRC_URI').split() | 2112 | uris = self.d.getVar('SRC_URI').split() |
2113 | uri = uris[0] | 2113 | uri = uris[0] |
2114 | d = self.d | 2114 | d = self.d |
2115 | 2115 | ||
2116 | fetcher = bb.fetch2.Fetch(uris, d) | 2116 | fetcher = bb.fetch2.Fetch(uris, d) |
2117 | fetcher.download() | 2117 | if download: |
2118 | fetcher.download() | ||
2118 | ud = fetcher.ud[uri] | 2119 | ud = fetcher.ud[uri] |
2119 | return fetcher, ud | 2120 | return fetcher, ud |
2120 | 2121 | ||
@@ -2124,16 +2125,21 @@ class GitLfsTest(FetcherTest): | |||
2124 | uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir | 2125 | uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir |
2125 | self.d.setVar('SRC_URI', uri) | 2126 | self.d.setVar('SRC_URI', uri) |
2126 | 2127 | ||
2127 | fetcher, ud = self.fetch() | 2128 | # Careful: suppress initial attempt at downloading until |
2129 | # we know whether git-lfs is installed. | ||
2130 | fetcher, ud = self.fetch(uri=None, download=False) | ||
2128 | self.assertIsNotNone(ud.method._find_git_lfs) | 2131 | self.assertIsNotNone(ud.method._find_git_lfs) |
2129 | 2132 | ||
2130 | # If git-lfs can be found, the unpack should be successful | 2133 | # If git-lfs can be found, the unpack should be successful. Only |
2131 | ud.method._find_git_lfs = lambda d: True | 2134 | # attempt this with the real live copy of git-lfs installed. |
2132 | shutil.rmtree(self.gitdir, ignore_errors=True) | 2135 | if ud.method._find_git_lfs(self.d): |
2133 | fetcher.unpack(self.d.getVar('WORKDIR')) | 2136 | fetcher.download() |
2137 | shutil.rmtree(self.gitdir, ignore_errors=True) | ||
2138 | fetcher.unpack(self.d.getVar('WORKDIR')) | ||
2134 | 2139 | ||
2135 | # If git-lfs cannot be found, the unpack should throw an error | 2140 | # If git-lfs cannot be found, the unpack should throw an error |
2136 | with self.assertRaises(bb.fetch2.FetchError): | 2141 | with self.assertRaises(bb.fetch2.FetchError): |
2142 | fetcher.download() | ||
2137 | ud.method._find_git_lfs = lambda d: False | 2143 | ud.method._find_git_lfs = lambda d: False |
2138 | shutil.rmtree(self.gitdir, ignore_errors=True) | 2144 | shutil.rmtree(self.gitdir, ignore_errors=True) |
2139 | fetcher.unpack(self.d.getVar('WORKDIR')) | 2145 | fetcher.unpack(self.d.getVar('WORKDIR')) |
@@ -2144,10 +2150,16 @@ class GitLfsTest(FetcherTest): | |||
2144 | uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir | 2150 | uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir |
2145 | self.d.setVar('SRC_URI', uri) | 2151 | self.d.setVar('SRC_URI', uri) |
2146 | 2152 | ||
2153 | # In contrast to test_lfs_enabled(), allow the implicit download | ||
2154 | # done by self.fetch() to occur here. The point of this test case | ||
2155 | # is to verify that the fetcher can survive even if the source | ||
2156 | # repository has Git LFS usage configured. | ||
2147 | fetcher, ud = self.fetch() | 2157 | fetcher, ud = self.fetch() |
2148 | self.assertIsNotNone(ud.method._find_git_lfs) | 2158 | self.assertIsNotNone(ud.method._find_git_lfs) |
2149 | 2159 | ||
2150 | # If git-lfs can be found, the unpack should be successful | 2160 | # If git-lfs can be found, the unpack should be successful. A |
2161 | # live copy of git-lfs is not required for this case, so | ||
2162 | # unconditionally forge its presence. | ||
2151 | ud.method._find_git_lfs = lambda d: True | 2163 | ud.method._find_git_lfs = lambda d: True |
2152 | shutil.rmtree(self.gitdir, ignore_errors=True) | 2164 | shutil.rmtree(self.gitdir, ignore_errors=True) |
2153 | fetcher.unpack(self.d.getVar('WORKDIR')) | 2165 | fetcher.unpack(self.d.getVar('WORKDIR')) |