diff options
| author | Stefan Koch <stefan-koch@siemens.com> | 2025-03-03 14:49:12 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-03-06 11:16:46 +0000 |
| commit | db267f2c94ec86e4a7c046c49d3a2260760ccbfa (patch) | |
| tree | b855cac671fb000c51538704b28c667d3913541a /bitbake/lib/bb | |
| parent | 22728acd78d65e993215a7f94cbf692d3111a4c4 (diff) | |
| download | poky-db267f2c94ec86e4a7c046c49d3a2260760ccbfa.tar.gz | |
bitbake: tests/fetch: Adapt test cases for fast shallow fetches
- Address the absence of an initial full bare clone
- Utilize the initial shallow clone
- Modify existing test cases for this behavior
- Remove incompatible test cases
(Bitbake rev: 599fedacd7782dcb52825c22200f35344c102548)
Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
| -rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 48b9e4af16..4a5af71061 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
| @@ -1814,7 +1814,6 @@ class GitShallowTest(FetcherTest): | |||
| 1814 | def fetch_shallow(self, uri=None, disabled=False, keepclone=False): | 1814 | def fetch_shallow(self, uri=None, disabled=False, keepclone=False): |
| 1815 | """Fetch a uri, generating a shallow tarball, then unpack using it""" | 1815 | """Fetch a uri, generating a shallow tarball, then unpack using it""" |
| 1816 | fetcher, ud = self.fetch_and_unpack(uri) | 1816 | fetcher, ud = self.fetch_and_unpack(uri) |
| 1817 | assert os.path.exists(ud.clonedir), 'Git clone in DLDIR (%s) does not exist for uri %s' % (ud.clonedir, uri) | ||
| 1818 | 1817 | ||
| 1819 | # Confirm that the unpacked repo is unshallow | 1818 | # Confirm that the unpacked repo is unshallow |
| 1820 | if not disabled: | 1819 | if not disabled: |
| @@ -1822,9 +1821,10 @@ class GitShallowTest(FetcherTest): | |||
| 1822 | 1821 | ||
| 1823 | # fetch and unpack, from the shallow tarball | 1822 | # fetch and unpack, from the shallow tarball |
| 1824 | bb.utils.remove(self.gitdir, recurse=True) | 1823 | bb.utils.remove(self.gitdir, recurse=True) |
| 1825 | bb.process.run('chmod u+w -R "%s"' % ud.clonedir) | 1824 | if os.path.exists(ud.clonedir): |
| 1826 | bb.utils.remove(ud.clonedir, recurse=True) | 1825 | bb.process.run('chmod u+w -R "%s"' % ud.clonedir) |
| 1827 | bb.utils.remove(ud.clonedir.replace('gitsource', 'gitsubmodule'), recurse=True) | 1826 | bb.utils.remove(ud.clonedir, recurse=True) |
| 1827 | bb.utils.remove(ud.clonedir.replace('gitsource', 'gitsubmodule'), recurse=True) | ||
| 1828 | 1828 | ||
| 1829 | # confirm that the unpacked repo is used when no git clone or git | 1829 | # confirm that the unpacked repo is used when no git clone or git |
| 1830 | # mirror tarball is available | 1830 | # mirror tarball is available |
| @@ -1907,7 +1907,12 @@ class GitShallowTest(FetcherTest): | |||
| 1907 | self.add_empty_file('c') | 1907 | self.add_empty_file('c') |
| 1908 | self.assertRevCount(3, cwd=self.srcdir) | 1908 | self.assertRevCount(3, cwd=self.srcdir) |
| 1909 | 1909 | ||
| 1910 | # Clone without tarball | ||
| 1911 | self.d.setVar('BB_GIT_SHALLOW', '0') | ||
| 1912 | fetcher, ud = self.fetch() | ||
| 1913 | |||
| 1910 | # Clone and generate mirror tarball | 1914 | # Clone and generate mirror tarball |
| 1915 | self.d.setVar('BB_GIT_SHALLOW', '1') | ||
| 1911 | fetcher, ud = self.fetch() | 1916 | fetcher, ud = self.fetch() |
| 1912 | 1917 | ||
| 1913 | # Ensure we have a current mirror tarball, but an out of date clone | 1918 | # Ensure we have a current mirror tarball, but an out of date clone |
| @@ -1919,6 +1924,7 @@ class GitShallowTest(FetcherTest): | |||
| 1919 | fetcher, ud = self.fetch() | 1924 | fetcher, ud = self.fetch() |
| 1920 | fetcher.unpack(self.d.getVar('WORKDIR')) | 1925 | fetcher.unpack(self.d.getVar('WORKDIR')) |
| 1921 | self.assertRevCount(1) | 1926 | self.assertRevCount(1) |
| 1927 | assert os.path.exists(os.path.join(self.d.getVar('WORKDIR'), 'git', 'c')) | ||
| 1922 | 1928 | ||
| 1923 | def test_shallow_single_branch_no_merge(self): | 1929 | def test_shallow_single_branch_no_merge(self): |
| 1924 | self.add_empty_file('a') | 1930 | self.add_empty_file('a') |
| @@ -2116,11 +2122,12 @@ class GitShallowTest(FetcherTest): | |||
| 2116 | self.add_empty_file('b') | 2122 | self.add_empty_file('b') |
| 2117 | 2123 | ||
| 2118 | # Fetch once to generate the shallow tarball | 2124 | # Fetch once to generate the shallow tarball |
| 2125 | self.d.setVar('BB_GIT_SHALLOW', '0') | ||
| 2119 | fetcher, ud = self.fetch() | 2126 | fetcher, ud = self.fetch() |
| 2120 | assert os.path.exists(os.path.join(self.dldir, ud.mirrortarballs[0])) | ||
| 2121 | 2127 | ||
| 2122 | # Fetch and unpack with both the clonedir and shallow tarball available | 2128 | # Fetch and unpack with both the clonedir and shallow tarball available |
| 2123 | bb.utils.remove(self.gitdir, recurse=True) | 2129 | bb.utils.remove(self.gitdir, recurse=True) |
| 2130 | self.d.setVar('BB_GIT_SHALLOW', '1') | ||
| 2124 | fetcher, ud = self.fetch_and_unpack() | 2131 | fetcher, ud = self.fetch_and_unpack() |
| 2125 | 2132 | ||
| 2126 | # The unpacked tree should *not* be shallow | 2133 | # The unpacked tree should *not* be shallow |
| @@ -2295,20 +2302,6 @@ class GitShallowTest(FetcherTest): | |||
| 2295 | self.assertIn("No up to date source found", context.exception.msg) | 2302 | self.assertIn("No up to date source found", context.exception.msg) |
| 2296 | self.assertIn("clone directory not available or not up to date", context.exception.msg) | 2303 | self.assertIn("clone directory not available or not up to date", context.exception.msg) |
| 2297 | 2304 | ||
| 2298 | @skipIfNoNetwork() | ||
| 2299 | def test_that_unpack_does_work_when_using_git_shallow_tarball_but_tarball_is_not_available(self): | ||
| 2300 | self.d.setVar('SRCREV', 'e5939ff608b95cdd4d0ab0e1935781ab9a276ac0') | ||
| 2301 | self.d.setVar('BB_GIT_SHALLOW', '1') | ||
| 2302 | self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '1') | ||
| 2303 | fetcher = bb.fetch.Fetch(["git://git.yoctoproject.org/fstests;branch=master;protocol=https"], self.d) | ||
| 2304 | fetcher.download() | ||
| 2305 | |||
| 2306 | bb.utils.remove(self.dldir + "/*.tar.gz") | ||
| 2307 | fetcher.unpack(self.unpackdir) | ||
| 2308 | |||
| 2309 | dir = os.listdir(self.unpackdir + "/git/") | ||
| 2310 | self.assertIn("fstests.doap", dir) | ||
| 2311 | |||
| 2312 | class GitLfsTest(FetcherTest): | 2305 | class GitLfsTest(FetcherTest): |
| 2313 | def skipIfNoGitLFS(): | 2306 | def skipIfNoGitLFS(): |
| 2314 | import shutil | 2307 | import shutil |
