diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 971c613ddd..64cc9fa76b 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -680,6 +680,38 @@ class FetcherLocalTest(FetcherTest): | |||
680 | unpack_rev = stdout[0].strip() | 680 | unpack_rev = stdout[0].strip() |
681 | self.assertEqual(orig_rev, unpack_rev) | 681 | self.assertEqual(orig_rev, unpack_rev) |
682 | 682 | ||
683 | def test_local_gitfetch_usehead_withname(self): | ||
684 | # Create dummy local Git repo | ||
685 | src_dir = tempfile.mkdtemp(dir=self.tempdir, | ||
686 | prefix='gitfetch_localusehead_') | ||
687 | src_dir = os.path.abspath(src_dir) | ||
688 | bb.process.run("git init", cwd=src_dir) | ||
689 | bb.process.run("git commit --allow-empty -m'Dummy commit'", | ||
690 | cwd=src_dir) | ||
691 | # Use other branch than master | ||
692 | bb.process.run("git checkout -b my-devel", cwd=src_dir) | ||
693 | bb.process.run("git commit --allow-empty -m'Dummy commit 2'", | ||
694 | cwd=src_dir) | ||
695 | stdout = bb.process.run("git rev-parse HEAD", cwd=src_dir) | ||
696 | orig_rev = stdout[0].strip() | ||
697 | |||
698 | # Fetch and check revision | ||
699 | self.d.setVar("SRCREV", "AUTOINC") | ||
700 | url = "git://" + src_dir + ";protocol=file;usehead=1;name=newName" | ||
701 | try: | ||
702 | fetcher = bb.fetch.Fetch([url], self.d) | ||
703 | except Exception: | ||
704 | # TODO: We currently expect this test to fail. Drop the try and | ||
705 | # assert when usehead has been fixed. | ||
706 | return | ||
707 | self.assertEqual(1, 0) | ||
708 | fetcher.download() | ||
709 | fetcher.unpack(self.unpackdir) | ||
710 | stdout = bb.process.run("git rev-parse HEAD", | ||
711 | cwd=os.path.join(self.unpackdir, 'git')) | ||
712 | unpack_rev = stdout[0].strip() | ||
713 | self.assertEqual(orig_rev, unpack_rev) | ||
714 | |||
683 | class FetcherNoNetworkTest(FetcherTest): | 715 | class FetcherNoNetworkTest(FetcherTest): |
684 | def setUp(self): | 716 | def setUp(self): |
685 | super().setUp() | 717 | super().setUp() |
@@ -879,6 +911,15 @@ class FetcherNetworkTest(FetcherTest): | |||
879 | self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url) | 911 | self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url) |
880 | 912 | ||
881 | @skipIfNoNetwork() | 913 | @skipIfNoNetwork() |
914 | def test_gitfetch_usehead_withname(self): | ||
915 | # Since self.gitfetcher() sets SRCREV we expect this to override | ||
916 | # `usehead=1' and instead fetch the specified SRCREV. See | ||
917 | # test_local_gitfetch_usehead() for a positive use of the usehead | ||
918 | # feature. | ||
919 | url = "git://git.openembedded.org/bitbake;usehead=1;name=newName" | ||
920 | self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url) | ||
921 | |||
922 | @skipIfNoNetwork() | ||
882 | def test_gitfetch_finds_local_tarball_for_mirrored_url_when_previous_downloaded_by_the_recipe_url(self): | 923 | def test_gitfetch_finds_local_tarball_for_mirrored_url_when_previous_downloaded_by_the_recipe_url(self): |
883 | recipeurl = "git://git.openembedded.org/bitbake" | 924 | recipeurl = "git://git.openembedded.org/bitbake" |
884 | mirrorurl = "git://someserver.org/bitbake" | 925 | mirrorurl = "git://someserver.org/bitbake" |