1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

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>
This commit is contained in:
Stefan Koch
2025-03-03 14:49:12 +01:00
committed by Richard Purdie
parent 22728acd78
commit db267f2c94
+12 -19
View File
@@ -1814,7 +1814,6 @@ class GitShallowTest(FetcherTest):
def fetch_shallow(self, uri=None, disabled=False, keepclone=False): def fetch_shallow(self, uri=None, disabled=False, keepclone=False):
"""Fetch a uri, generating a shallow tarball, then unpack using it""" """Fetch a uri, generating a shallow tarball, then unpack using it"""
fetcher, ud = self.fetch_and_unpack(uri) fetcher, ud = self.fetch_and_unpack(uri)
assert os.path.exists(ud.clonedir), 'Git clone in DLDIR (%s) does not exist for uri %s' % (ud.clonedir, uri)
# Confirm that the unpacked repo is unshallow # Confirm that the unpacked repo is unshallow
if not disabled: if not disabled:
@@ -1822,9 +1821,10 @@ class GitShallowTest(FetcherTest):
# fetch and unpack, from the shallow tarball # fetch and unpack, from the shallow tarball
bb.utils.remove(self.gitdir, recurse=True) bb.utils.remove(self.gitdir, recurse=True)
bb.process.run('chmod u+w -R "%s"' % ud.clonedir) if os.path.exists(ud.clonedir):
bb.utils.remove(ud.clonedir, recurse=True) bb.process.run('chmod u+w -R "%s"' % ud.clonedir)
bb.utils.remove(ud.clonedir.replace('gitsource', 'gitsubmodule'), recurse=True) bb.utils.remove(ud.clonedir, recurse=True)
bb.utils.remove(ud.clonedir.replace('gitsource', 'gitsubmodule'), recurse=True)
# confirm that the unpacked repo is used when no git clone or git # confirm that the unpacked repo is used when no git clone or git
# mirror tarball is available # mirror tarball is available
@@ -1907,7 +1907,12 @@ class GitShallowTest(FetcherTest):
self.add_empty_file('c') self.add_empty_file('c')
self.assertRevCount(3, cwd=self.srcdir) self.assertRevCount(3, cwd=self.srcdir)
# Clone without tarball
self.d.setVar('BB_GIT_SHALLOW', '0')
fetcher, ud = self.fetch()
# Clone and generate mirror tarball # Clone and generate mirror tarball
self.d.setVar('BB_GIT_SHALLOW', '1')
fetcher, ud = self.fetch() fetcher, ud = self.fetch()
# Ensure we have a current mirror tarball, but an out of date clone # Ensure we have a current mirror tarball, but an out of date clone
@@ -1919,6 +1924,7 @@ class GitShallowTest(FetcherTest):
fetcher, ud = self.fetch() fetcher, ud = self.fetch()
fetcher.unpack(self.d.getVar('WORKDIR')) fetcher.unpack(self.d.getVar('WORKDIR'))
self.assertRevCount(1) self.assertRevCount(1)
assert os.path.exists(os.path.join(self.d.getVar('WORKDIR'), 'git', 'c'))
def test_shallow_single_branch_no_merge(self): def test_shallow_single_branch_no_merge(self):
self.add_empty_file('a') self.add_empty_file('a')
@@ -2116,11 +2122,12 @@ class GitShallowTest(FetcherTest):
self.add_empty_file('b') self.add_empty_file('b')
# Fetch once to generate the shallow tarball # Fetch once to generate the shallow tarball
self.d.setVar('BB_GIT_SHALLOW', '0')
fetcher, ud = self.fetch() fetcher, ud = self.fetch()
assert os.path.exists(os.path.join(self.dldir, ud.mirrortarballs[0]))
# Fetch and unpack with both the clonedir and shallow tarball available # Fetch and unpack with both the clonedir and shallow tarball available
bb.utils.remove(self.gitdir, recurse=True) bb.utils.remove(self.gitdir, recurse=True)
self.d.setVar('BB_GIT_SHALLOW', '1')
fetcher, ud = self.fetch_and_unpack() fetcher, ud = self.fetch_and_unpack()
# The unpacked tree should *not* be shallow # The unpacked tree should *not* be shallow
@@ -2295,20 +2302,6 @@ class GitShallowTest(FetcherTest):
self.assertIn("No up to date source found", context.exception.msg) self.assertIn("No up to date source found", context.exception.msg)
self.assertIn("clone directory not available or not up to date", context.exception.msg) self.assertIn("clone directory not available or not up to date", context.exception.msg)
@skipIfNoNetwork()
def test_that_unpack_does_work_when_using_git_shallow_tarball_but_tarball_is_not_available(self):
self.d.setVar('SRCREV', 'e5939ff608b95cdd4d0ab0e1935781ab9a276ac0')
self.d.setVar('BB_GIT_SHALLOW', '1')
self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '1')
fetcher = bb.fetch.Fetch(["git://git.yoctoproject.org/fstests;branch=master;protocol=https"], self.d)
fetcher.download()
bb.utils.remove(self.dldir + "/*.tar.gz")
fetcher.unpack(self.unpackdir)
dir = os.listdir(self.unpackdir + "/git/")
self.assertIn("fstests.doap", dir)
class GitLfsTest(FetcherTest): class GitLfsTest(FetcherTest):
def skipIfNoGitLFS(): def skipIfNoGitLFS():
import shutil import shutil