@@ -1739,7 +1739,14 @@ class GitMakeShallowTest(FetcherTest):
self.make_shallow(['refs/tags/1.10.0'])
self.assertRevCount(orig_revs - 1746, ['--all'])
-class GitShallowTest(FetcherTest):
+class GitShallowBaseTest():
+ """
+ Test cases for the default fast shallow mode and the skipped fast shallow mode.
+ Test cases must succeed with `ud.shallow_skip_fast` set to either `0` or `1`.
+ The class GitShallowTest contains all test cases used with `ud.shallow_skip_fast == 0`.
+ The class GitShallowSkipFastTest contains all test cases used with `ud.shallow_skip_fast == 1`.
+ """
+
def setUp(self):
FetcherTest.setUp(self)
self.gitdir = os.path.join(self.tempdir, 'git')
@@ -1814,7 +1821,8 @@ class GitShallowTest(FetcherTest):
def fetch_shallow(self, uri=None, disabled=False, keepclone=False):
"""Fetch a uri, generating a shallow tarball, then unpack using it"""
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)
+ if ud.shallow_skip_fast:
+ 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
if not disabled:
@@ -1822,9 +1830,10 @@ class GitShallowTest(FetcherTest):
# fetch and unpack, from the shallow tarball
bb.utils.remove(self.gitdir, recurse=True)
- bb.process.run('chmod u+w -R "%s"' % ud.clonedir)
- bb.utils.remove(ud.clonedir, recurse=True)
- bb.utils.remove(ud.clonedir.replace('gitsource', 'gitsubmodule'), recurse=True)
+ if ud.shallow_skip_fast:
+ bb.process.run('chmod u+w -R "%s"' % ud.clonedir)
+ 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
# mirror tarball is available
@@ -1907,7 +1916,12 @@ class GitShallowTest(FetcherTest):
self.add_empty_file('c')
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
+ self.d.setVar('BB_GIT_SHALLOW', '1')
fetcher, ud = self.fetch()
# Ensure we have a current mirror tarball, but an out of date clone
@@ -1919,6 +1933,7 @@ class GitShallowTest(FetcherTest):
fetcher, ud = self.fetch()
fetcher.unpack(self.d.getVar('WORKDIR'))
self.assertRevCount(1)
+ assert os.path.exists(os.path.join(self.d.getVar('WORKDIR'), 'git', 'c'))
def test_shallow_single_branch_no_merge(self):
self.add_empty_file('a')
@@ -2116,11 +2131,12 @@ class GitShallowTest(FetcherTest):
self.add_empty_file('b')
# Fetch once to generate the shallow tarball
+ self.d.setVar('BB_GIT_SHALLOW', '0')
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
bb.utils.remove(self.gitdir, recurse=True)
+ self.d.setVar('BB_GIT_SHALLOW', '1')
fetcher, ud = self.fetch_and_unpack()
# The unpacked tree should *not* be shallow
@@ -2295,6 +2311,27 @@ class GitShallowTest(FetcherTest):
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)
+class GitShallowTest(GitShallowBaseTest, FetcherTest):
+ """
+ Test cases for use with default fast shallow mode.
+ The class contains all test cases used with `ud.shallow_skip_fast == 1` only.
+ """
+
+ def setUp(self):
+ FetcherTest.setUp(self)
+ GitShallowBaseTest.setUp(self)
+
+class GitShallowSkipFastTest(GitShallowBaseTest, FetcherTest):
+ """
+ Test cases for use when skipping fast shallow mode.
+ The class contains all test cases used with `ud.shallow_skip_fast == 0` only.
+ """
+
+ def setUp(self):
+ FetcherTest.setUp(self)
+ GitShallowBaseTest.setUp(self)
+ self.d.setVar('BB_GIT_SHALLOW_SKIP_FAST', '1')
+
@skipIfNoNetwork()
def test_that_unpack_does_work_when_using_git_shallow_tarball_but_tarball_is_not_available(self):
self.d.setVar('SRCREV', 'e5939ff608b95cdd4d0ab0e1935781ab9a276ac0')
- The base class GitShallowBaseTest contains all test cases for the default fast shallow mode and the skipped fast shallow mode - The class GitShallowFastTest contains all test cases used with `ud.shallow_skip_fast == 0` - The class GitShallowSkipFastTest contains all test cases used with `ud.shallow_skip_fast == 1` 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 Signed-off-by: Stefan Koch <stefan-koch@siemens.com> --- lib/bb/tests/fetch.py | 49 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-)