aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Degges <jdegges@gmail.com>2021-01-04 21:14:55 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-01-05 23:14:32 +0000
commita2345110f217fac429f6ec15f699c87c39531e7c (patch)
treee6a83ee6b69f01af203d59175d60220cd029fee8
parent1cd998c19101e3b093e81c126b3048c5d56058b0 (diff)
downloadbitbake-a2345110f217fac429f6ec15f699c87c39531e7c.tar.gz
tests/fetch: Test usehead with a non-default name
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. Signed-off-by: Joey Degges <jdegges@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/tests/fetch.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 971c613dd..64cc9fa76 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -680,6 +680,38 @@ class FetcherLocalTest(FetcherTest):
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()
@@ -879,6 +911,15 @@ class FetcherNetworkTest(FetcherTest):
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"
mirrorurl = "git://someserver.org/bitbake"