From: Henning Schild <henning.schild@siemens.com>
To: bitbake-devel@lists.openembedded.org
Cc: isar-users@googlegroups.com,
Richard Purdie <richard.purdie@linuxfoundation.org>,
Cedric Hombourger <Cedric_Hombourger@mentor.com>,
Chris Larson <Chris_Larson@mentor.com>,
Henning Schild <henning.schild@siemens.com>
Subject: [PATCH v3 2/3] tests/fetch: deduplicate local git testing code
Date: Wed, 14 Apr 2021 08:32:40 +0200 [thread overview]
Message-ID: <20210414063241.18528-2-henning.schild@siemens.com> (raw)
In-Reply-To: <20210414063241.18528-1-henning.schild@siemens.com>
Purely cosmetic change that probably improves the code.
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
lib/bb/tests/fetch.py | 34 ++++++----------------------------
1 file changed, 6 insertions(+), 28 deletions(-)
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index b921a952e493..ab02bc74ac15 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -674,7 +674,7 @@ class FetcherLocalTest(FetcherTest):
with self.assertRaises(bb.fetch2.UnpackError):
self.fetchUnpack(['file://a;subdir=/bin/sh'])
- def test_local_gitfetch_usehead(self):
+ def dummyGitTest(self, suffix):
# Create dummy local Git repo
src_dir = tempfile.mkdtemp(dir=self.tempdir,
prefix='gitfetch_localusehead_')
@@ -693,7 +693,7 @@ class FetcherLocalTest(FetcherTest):
# Fetch and check revision
self.d.setVar("SRCREV", "AUTOINC")
- url = "git://" + src_dir + ";protocol=file;usehead=1"
+ url = "git://" + src_dir + ";protocol=file;" + suffix
fetcher = bb.fetch.Fetch([url], self.d)
fetcher.download()
fetcher.unpack(self.unpackdir)
@@ -702,33 +702,11 @@ 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 config user.email 'you@example.com'", cwd=src_dir)
- bb.process.run("git config user.name 'Your Name'", 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()
+ def test_local_gitfetch_usehead(self):
+ self.dummyGitTest("usehead=1")
- # Fetch and check revision
- self.d.setVar("SRCREV", "AUTOINC")
- url = "git://" + src_dir + ";protocol=file;usehead=1;name=newName"
- fetcher = bb.fetch.Fetch([url], self.d)
- 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)
+ def test_local_gitfetch_usehead_withname(self):
+ self.dummyGitTest("usehead=1;name=newName")
class FetcherNoNetworkTest(FetcherTest):
def setUp(self):
--
2.26.3
next prev parent reply other threads:[~2021-04-14 6:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 6:32 [PATCH v3 1/3] fetch/git: add support for disabling shared clones on unpack Henning Schild
2021-04-14 6:32 ` Henning Schild [this message]
2021-04-14 6:32 ` [PATCH v3 3/3] tests/fetch: add tests for local and remote "noshared" git fetching Henning Schild
2021-04-27 16:53 ` [PATCH v3 1/3] fetch/git: add support for disabling shared clones on unpack Henning Schild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210414063241.18528-2-henning.schild@siemens.com \
--to=henning.schild@siemens.com \
--cc=Cedric_Hombourger@mentor.com \
--cc=Chris_Larson@mentor.com \
--cc=bitbake-devel@lists.openembedded.org \
--cc=isar-users@googlegroups.com \
--cc=richard.purdie@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox