Skip to content

Commit

Permalink
bitbake: tests/fetch: Test usehead with a non-default name
Browse files Browse the repository at this point in the history
Add tests for fetching a URL with the usehead parameter set and a
non-default name set. We currently expect the local version of this test
to fail since there is a bug in the usehead implementation that breaks
for non-default names.

(Bitbake rev: a2345110f217fac429f6ec15f699c87c39531e7c)

Signed-off-by: Joey Degges <jdegges@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
  • Loading branch information
jdegges authored and rpurdie committed Jan 8, 2021
1 parent d5c4cd6 commit 41ed881
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions bitbake/lib/bb/tests/fetch.py
Expand Up @@ -680,6 +680,38 @@ def test_local_gitfetch_usehead(self):
unpack_rev = stdout[0].strip()
self.assertEqual(orig_rev, unpack_rev)

def test_local_gitfetch_usehead_withname(self):
# Create dummy local Git repo
src_dir = tempfile.mkdtemp(dir=self.tempdir,
prefix='gitfetch_localusehead_')
src_dir = os.path.abspath(src_dir)
bb.process.run("git init", cwd=src_dir)
bb.process.run("git commit --allow-empty -m'Dummy commit'",
cwd=src_dir)
# Use other branch than master
bb.process.run("git checkout -b my-devel", cwd=src_dir)
bb.process.run("git commit --allow-empty -m'Dummy commit 2'",
cwd=src_dir)
stdout = bb.process.run("git rev-parse HEAD", cwd=src_dir)
orig_rev = stdout[0].strip()

# Fetch and check revision
self.d.setVar("SRCREV", "AUTOINC")
url = "git://" + src_dir + ";protocol=file;usehead=1;name=newName"
try:
fetcher = bb.fetch.Fetch([url], self.d)
except Exception:
# TODO: We currently expect this test to fail. Drop the try and
# assert when usehead has been fixed.
return
self.assertEqual(1, 0)
fetcher.download()
fetcher.unpack(self.unpackdir)
stdout = bb.process.run("git rev-parse HEAD",
cwd=os.path.join(self.unpackdir, 'git'))
unpack_rev = stdout[0].strip()
self.assertEqual(orig_rev, unpack_rev)

class FetcherNoNetworkTest(FetcherTest):
def setUp(self):
super().setUp()
Expand Down Expand Up @@ -878,6 +910,15 @@ def test_gitfetch_usehead(self):
url = "git://git.openembedded.org/bitbake;usehead=1"
self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url)

@skipIfNoNetwork()
def test_gitfetch_usehead_withname(self):
# Since self.gitfetcher() sets SRCREV we expect this to override
# `usehead=1' and instead fetch the specified SRCREV. See
# test_local_gitfetch_usehead() for a positive use of the usehead
# feature.
url = "git://git.openembedded.org/bitbake;usehead=1;name=newName"
self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url)

@skipIfNoNetwork()
def test_gitfetch_finds_local_tarball_for_mirrored_url_when_previous_downloaded_by_the_recipe_url(self):
recipeurl = "git://git.openembedded.org/bitbake"
Expand Down

0 comments on commit 41ed881

Please sign in to comment.