diff options
author | Henning Schild <henning.schild@siemens.com> | 2021-04-14 08:32:40 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-04-18 11:38:22 +0100 |
commit | d274cf0cf8af4094bee2595de8c14d689c5bcdcb (patch) | |
tree | d0cb84bdd16f56ba2682c466ae00ec3728815057 /bitbake | |
parent | 2cb6ce778804deb9666cf09a7ada787c9f7936cf (diff) | |
download | poky-d274cf0cf8af4094bee2595de8c14d689c5bcdcb.tar.gz |
bitbake: tests/fetch: deduplicate local git testing code
Purely cosmetic change that probably improves the code.
(Bitbake rev: 9c0733f0062f3cf19514c891cc06c9a8e0db429b)
Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index b921a952e4..ab02bc74ac 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -674,7 +674,7 @@ class FetcherLocalTest(FetcherTest): | |||
674 | with self.assertRaises(bb.fetch2.UnpackError): | 674 | with self.assertRaises(bb.fetch2.UnpackError): |
675 | self.fetchUnpack(['file://a;subdir=/bin/sh']) | 675 | self.fetchUnpack(['file://a;subdir=/bin/sh']) |
676 | 676 | ||
677 | def test_local_gitfetch_usehead(self): | 677 | def dummyGitTest(self, suffix): |
678 | # Create dummy local Git repo | 678 | # Create dummy local Git repo |
679 | src_dir = tempfile.mkdtemp(dir=self.tempdir, | 679 | src_dir = tempfile.mkdtemp(dir=self.tempdir, |
680 | prefix='gitfetch_localusehead_') | 680 | prefix='gitfetch_localusehead_') |
@@ -693,7 +693,7 @@ class FetcherLocalTest(FetcherTest): | |||
693 | 693 | ||
694 | # Fetch and check revision | 694 | # Fetch and check revision |
695 | self.d.setVar("SRCREV", "AUTOINC") | 695 | self.d.setVar("SRCREV", "AUTOINC") |
696 | url = "git://" + src_dir + ";protocol=file;usehead=1" | 696 | url = "git://" + src_dir + ";protocol=file;" + suffix |
697 | fetcher = bb.fetch.Fetch([url], self.d) | 697 | fetcher = bb.fetch.Fetch([url], self.d) |
698 | fetcher.download() | 698 | fetcher.download() |
699 | fetcher.unpack(self.unpackdir) | 699 | fetcher.unpack(self.unpackdir) |
@@ -702,33 +702,11 @@ class FetcherLocalTest(FetcherTest): | |||
702 | unpack_rev = stdout[0].strip() | 702 | unpack_rev = stdout[0].strip() |
703 | self.assertEqual(orig_rev, unpack_rev) | 703 | self.assertEqual(orig_rev, unpack_rev) |
704 | 704 | ||
705 | def test_local_gitfetch_usehead_withname(self): | 705 | def test_local_gitfetch_usehead(self): |
706 | # Create dummy local Git repo | 706 | self.dummyGitTest("usehead=1") |
707 | src_dir = tempfile.mkdtemp(dir=self.tempdir, | ||
708 | prefix='gitfetch_localusehead_') | ||
709 | src_dir = os.path.abspath(src_dir) | ||
710 | bb.process.run("git init", cwd=src_dir) | ||
711 | bb.process.run("git config user.email 'you@example.com'", cwd=src_dir) | ||
712 | bb.process.run("git config user.name 'Your Name'", cwd=src_dir) | ||
713 | bb.process.run("git commit --allow-empty -m'Dummy commit'", | ||
714 | cwd=src_dir) | ||
715 | # Use other branch than master | ||
716 | bb.process.run("git checkout -b my-devel", cwd=src_dir) | ||
717 | bb.process.run("git commit --allow-empty -m'Dummy commit 2'", | ||
718 | cwd=src_dir) | ||
719 | stdout = bb.process.run("git rev-parse HEAD", cwd=src_dir) | ||
720 | orig_rev = stdout[0].strip() | ||
721 | 707 | ||
722 | # Fetch and check revision | 708 | def test_local_gitfetch_usehead_withname(self): |
723 | self.d.setVar("SRCREV", "AUTOINC") | 709 | self.dummyGitTest("usehead=1;name=newName") |
724 | url = "git://" + src_dir + ";protocol=file;usehead=1;name=newName" | ||
725 | fetcher = bb.fetch.Fetch([url], self.d) | ||
726 | fetcher.download() | ||
727 | fetcher.unpack(self.unpackdir) | ||
728 | stdout = bb.process.run("git rev-parse HEAD", | ||
729 | cwd=os.path.join(self.unpackdir, 'git')) | ||
730 | unpack_rev = stdout[0].strip() | ||
731 | self.assertEqual(orig_rev, unpack_rev) | ||
732 | 710 | ||
733 | class FetcherNoNetworkTest(FetcherTest): | 711 | class FetcherNoNetworkTest(FetcherTest): |
734 | def setUp(self): | 712 | def setUp(self): |