summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/tests/fetch.py55
1 files changed, 27 insertions, 28 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index da17d7f281..1323ac2cd3 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -654,6 +654,32 @@ class FetcherLocalTest(FetcherTest):
654 with self.assertRaises(bb.fetch2.UnpackError): 654 with self.assertRaises(bb.fetch2.UnpackError):
655 self.fetchUnpack(['file://a;subdir=/bin/sh']) 655 self.fetchUnpack(['file://a;subdir=/bin/sh'])
656 656
657 def test_local_gitfetch_usehead(self):
658 # Create dummy local Git repo
659 src_dir = tempfile.mkdtemp(dir=self.tempdir,
660 prefix='gitfetch_localusehead_')
661 src_dir = os.path.abspath(src_dir)
662 bb.process.run("git init", cwd=src_dir)
663 bb.process.run("git commit --allow-empty -m'Dummy commit'",
664 cwd=src_dir)
665 # Use other branch than master
666 bb.process.run("git checkout -b my-devel", cwd=src_dir)
667 bb.process.run("git commit --allow-empty -m'Dummy commit 2'",
668 cwd=src_dir)
669 stdout = bb.process.run("git rev-parse HEAD", cwd=src_dir)
670 orig_rev = stdout[0].strip()
671
672 # Fetch and check revision
673 self.d.setVar("SRCREV", "AUTOINC")
674 url = "git://" + src_dir + ";protocol=file;usehead=1"
675 fetcher = bb.fetch.Fetch([url], self.d)
676 fetcher.download()
677 fetcher.unpack(self.unpackdir)
678 stdout = bb.process.run("git rev-parse HEAD",
679 cwd=os.path.join(self.unpackdir, 'git'))
680 unpack_rev = stdout[0].strip()
681 self.assertEqual(orig_rev, unpack_rev)
682
657class FetcherNoNetworkTest(FetcherTest): 683class FetcherNoNetworkTest(FetcherTest):
658 def setUp(self): 684 def setUp(self):
659 super().setUp() 685 super().setUp()
@@ -844,34 +870,7 @@ class FetcherNetworkTest(FetcherTest):
844 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2) 870 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
845 871
846 @skipIfNoNetwork() 872 @skipIfNoNetwork()
847 def test_gitfetch_localusehead(self): 873 def test_gitfetch_usehead(self):
848 # Create dummy local Git repo
849 src_dir = tempfile.mkdtemp(dir=self.tempdir,
850 prefix='gitfetch_localusehead_')
851 src_dir = os.path.abspath(src_dir)
852 bb.process.run("git init", cwd=src_dir)
853 bb.process.run("git commit --allow-empty -m'Dummy commit'",
854 cwd=src_dir)
855 # Use other branch than master
856 bb.process.run("git checkout -b my-devel", cwd=src_dir)
857 bb.process.run("git commit --allow-empty -m'Dummy commit 2'",
858 cwd=src_dir)
859 stdout = bb.process.run("git rev-parse HEAD", cwd=src_dir)
860 orig_rev = stdout[0].strip()
861
862 # Fetch and check revision
863 self.d.setVar("SRCREV", "AUTOINC")
864 url = "git://" + src_dir + ";protocol=file;usehead=1"
865 fetcher = bb.fetch.Fetch([url], self.d)
866 fetcher.download()
867 fetcher.unpack(self.unpackdir)
868 stdout = bb.process.run("git rev-parse HEAD",
869 cwd=os.path.join(self.unpackdir, 'git'))
870 unpack_rev = stdout[0].strip()
871 self.assertEqual(orig_rev, unpack_rev)
872
873 @skipIfNoNetwork()
874 def test_gitfetch_remoteusehead(self):
875 url = "git://git.openembedded.org/bitbake;usehead=1" 874 url = "git://git.openembedded.org/bitbake;usehead=1"
876 self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url) 875 self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url)
877 876