Lines Matching full:self

294     def test_uri(self):  argument
295 for test_uri, ref in self.test_uris.items():
298 self.assertEqual(str(uri), ref['uri'])
301 self.assertEqual(uri.scheme, ref['scheme'])
303 self.assertEqual(uri.userinfo, ref['userinfo'])
304 self.assertEqual(uri.username, ref['username'])
305 self.assertEqual(uri.password, ref['password'])
307 self.assertEqual(uri.hostname, ref['hostname'])
308 self.assertEqual(uri.port, ref['port'])
309 self.assertEqual(uri.hostport, ref['hostport'])
311 self.assertEqual(uri.path, ref['path'])
312 self.assertEqual(uri.params, ref['params'])
314 self.assertEqual(uri.relative, ref['relative'])
316 def test_dict(self): argument
317 for test in self.test_uris.values():
320 self.assertEqual(uri.scheme, '')
321 self.assertEqual(uri.userinfo, '')
322 self.assertEqual(uri.username, '')
323 self.assertEqual(uri.password, '')
324 self.assertEqual(uri.hostname, '')
325 self.assertEqual(uri.port, None)
326 self.assertEqual(uri.path, '')
327 self.assertEqual(uri.params, {})
331 self.assertEqual(uri.scheme, test['scheme'])
334 self.assertEqual(uri.userinfo, test['userinfo'])
335 self.assertEqual(uri.username, test['username'])
336 self.assertEqual(uri.password, test['password'])
340 self.assertEqual(uri.username, 'changeme')
341 self.assertEqual(uri.password, test['password'])
343 self.assertEqual(uri.username, 'changeme')
344 self.assertEqual(uri.password, 'insecure')
348 self.assertEqual(uri.userinfo, test['userinfo'])
349 self.assertEqual(uri.username, test['username'])
350 self.assertEqual(uri.password, test['password'])
353 self.assertEqual(uri.hostname, test['hostname'])
354 self.assertEqual(uri.hostport, test['hostname'])
357 self.assertEqual(uri.port, test['port'])
358 self.assertEqual(uri.hostport, test['hostport'])
361 self.assertEqual(uri.path, test['path'])
364 self.assertEqual(uri.params, test['params'])
367 self.assertEqual(uri.query, test['query'])
369 self.assertEqual(str(uri), test['uri'])
372 self.assertEqual(uri.params, {})
373 self.assertEqual(str(uri), (str(uri).split(";"))[0])
377 def setUp(self): argument
378 self.origdir = os.getcwd()
379 self.d = bb.data.init()
380 self.tempdir = tempfile.mkdtemp(prefix="bitbake-fetch-")
381 self.dldir = os.path.join(self.tempdir, "download")
382 os.mkdir(self.dldir)
383 self.d.setVar("DL_DIR", self.dldir)
384 self.unpackdir = os.path.join(self.tempdir, "unpacked")
385 os.mkdir(self.unpackdir)
386 persistdir = os.path.join(self.tempdir, "persistdata")
387 self.d.setVar("PERSISTENT_DIR", persistdir)
389 def tearDown(self): argument
390 os.chdir(self.origdir)
392 print("Not cleaning up %s. Please remove manually." % self.tempdir)
394 bb.process.run('chmod u+rw -R %s' % self.tempdir)
395 bb.utils.prunedir(self.tempdir)
397 def git(self, cmd, cwd=None): argument
403 cwd = self.gitdir
406 def git_init(self, cwd=None): argument
407 self.git('init', cwd=cwd)
408 if not self.git(['config', 'user.email'], cwd=cwd):
409 self.git(['config', 'user.email', 'you@example.com'], cwd=cwd)
410 if not self.git(['config', 'user.name'], cwd=cwd):
411 self.git(['config', 'user.name', 'Your Name'], cwd=cwd)
470 def test_urireplace(self): argument
471 for k, v in self.replaceuris.items():
472 ud = bb.fetch.FetchData(k[0], self.d)
473 ud.setup_localpath(self.d)
475 newuris, uds = bb.fetch2.build_mirroruris(ud, mirrors, self.d)
476 self.assertEqual([v], newuris)
478 def test_urilist1(self): argument
479 …bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d)
480 mirrors = bb.fetch2.mirror_from_string(self.mirrorvar)
481 uris, uds = bb.fetch2.build_mirroruris(fetcher, mirrors, self.d)
482self.assertEqual(uris, ['file:///somepath/downloads/bitbake-1.0.tar.gz', 'file:///someotherpath/do…
484 def test_urilist2(self): argument
486 …b.fetch.FetchData("https://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d)
487 mirrors = bb.fetch2.mirror_from_string(self.mirrorvar)
488 uris, uds = bb.fetch2.build_mirroruris(fetcher, mirrors, self.d)
489 self.assertEqual(uris, ['file:///someotherpath/downloads/bitbake-1.0.tar.gz'])
491 def test_mirror_of_mirror(self): argument
493 … mirrorvar = self.mirrorvar + " http://.*/.* http://otherdownloads.yoctoproject.org/downloads/"
495 …bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d)
497 uris, uds = bb.fetch2.build_mirroruris(fetcher, mirrors, self.d)
498 self.assertEqual(uris, ['file:///somepath/downloads/bitbake-1.0.tar.gz',
506 def test_recursive(self): argument
507 …b.fetch.FetchData("https://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d)
508 mirrors = bb.fetch2.mirror_from_string(self.recmirrorvar)
509 uris, uds = bb.fetch2.build_mirroruris(fetcher, mirrors, self.d)
510 self.assertEqual(uris, ['http://AAAA/A/A/A/bitbake/bitbake-1.0.tar.gz',
516 def setUp(self): argument
517 super(GitDownloadDirectoryNamingTest, self).setUp()
518 self.recipe_url = "git://git.openembedded.org/bitbake;branch=master"
519 self.recipe_dir = "git.openembedded.org.bitbake"
520 self.mirror_url = "git://github.com/openembedded/bitbake.git;protocol=https;branch=master"
521 self.mirror_dir = "github.com.openembedded.bitbake.git"
523 self.d.setVar('SRCREV', '82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40')
525 def setup_mirror_rewrite(self): argument
526 self.d.setVar("PREMIRRORS", self.recipe_url + " " + self.mirror_url)
529 def test_that_directory_is_named_after_recipe_url_when_no_mirroring_is_used(self): argument
530 self.setup_mirror_rewrite()
531 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
535 dir = os.listdir(self.dldir + "/git2")
536 self.assertIn(self.recipe_dir, dir)
539 def test_that_directory_exists_for_mirrored_url_and_recipe_url_when_mirroring_is_used(self): argument
540 self.setup_mirror_rewrite()
541 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
545 dir = os.listdir(self.dldir + "/git2")
546 self.assertIn(self.mirror_dir, dir)
547 self.assertIn(self.recipe_dir, dir)
550 …d_mirrored_directory_exists_when_mirroring_is_used_and_the_mirrored_directory_already_exists(self): argument
551 self.setup_mirror_rewrite()
552 fetcher = bb.fetch.Fetch([self.mirror_url], self.d)
554 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
558 dir = os.listdir(self.dldir + "/git2")
559 self.assertIn(self.mirror_dir, dir)
560 self.assertIn(self.recipe_dir, dir)
564 def setUp(self): argument
565 super(TarballNamingTest, self).setUp()
566 self.recipe_url = "git://git.openembedded.org/bitbake;branch=master"
567 self.recipe_tarball = "git2_git.openembedded.org.bitbake.tar.gz"
568 self.mirror_url = "git://github.com/openembedded/bitbake.git;protocol=https;branch=master"
569 self.mirror_tarball = "git2_github.com.openembedded.bitbake.git.tar.gz"
571 self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '1')
572 self.d.setVar('SRCREV', '82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40')
574 def setup_mirror_rewrite(self): argument
575 self.d.setVar("PREMIRRORS", self.recipe_url + " " + self.mirror_url)
578 def test_that_the_recipe_tarball_is_created_when_no_mirroring_is_used(self): argument
579 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
583 dir = os.listdir(self.dldir)
584 self.assertIn(self.recipe_tarball, dir)
587 def test_that_the_mirror_tarball_is_created_when_mirroring_is_used(self): argument
588 self.setup_mirror_rewrite()
589 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
593 dir = os.listdir(self.dldir)
594 self.assertIn(self.mirror_tarball, dir)
598 def setUp(self): argument
599 super(GitShallowTarballNamingTest, self).setUp()
600 self.recipe_url = "git://git.openembedded.org/bitbake;branch=master"
601 self.recipe_tarball = "gitshallow_git.openembedded.org.bitbake_82ea737-1_master.tar.gz"
602 self.mirror_url = "git://github.com/openembedded/bitbake.git;protocol=https;branch=master"
603self.mirror_tarball = "gitshallow_github.com.openembedded.bitbake.git_82ea737-1_master.tar.gz"
605 self.d.setVar('BB_GIT_SHALLOW', '1')
606 self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '1')
607 self.d.setVar('SRCREV', '82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40')
609 def setup_mirror_rewrite(self): argument
610 self.d.setVar("PREMIRRORS", self.recipe_url + " " + self.mirror_url)
613 def test_that_the_tarball_is_named_after_recipe_url_when_no_mirroring_is_used(self): argument
614 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
618 dir = os.listdir(self.dldir)
619 self.assertIn(self.recipe_tarball, dir)
622 def test_that_the_mirror_tarball_is_created_when_mirroring_is_used(self): argument
623 self.setup_mirror_rewrite()
624 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
628 dir = os.listdir(self.dldir)
629 self.assertIn(self.mirror_tarball, dir)
633 def setUp(self): argument
634 super(CleanTarballTest, self).setUp()
635 self.recipe_url = "git://git.openembedded.org/bitbake"
636 self.recipe_tarball = "git2_git.openembedded.org.bitbake.tar.gz"
638 self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '1')
639 self.d.setVar('SRCREV', '82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40')
642 def test_that_the_tarball_contents_does_not_leak_info(self): argument
643 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
647 fetcher.unpack(self.unpackdir)
649 cwd=os.path.join(self.unpackdir, 'git'))
650 self.assertEqual(len(mtime), 2)
653 archive = tarfile.open(os.path.join(self.dldir, self.recipe_tarball))
654 self.assertNotEqual(len(archive.members), 0)
656 self.assertEqual(member.uname, 'oe')
657 self.assertEqual(member.uid, 0)
658 self.assertEqual(member.gname, 'oe')
659 self.assertEqual(member.gid, 0)
660 self.assertEqual(member.mtime, mtime)
664 def setUp(self): argument
669 super(FetcherLocalTest, self).setUp()
670 self.localsrcdir = os.path.join(self.tempdir, 'localsrc')
671 os.makedirs(self.localsrcdir)
672 touch(os.path.join(self.localsrcdir, 'a'))
673 touch(os.path.join(self.localsrcdir, 'b'))
674 os.makedirs(os.path.join(self.localsrcdir, 'dir'))
675 touch(os.path.join(self.localsrcdir, 'dir', 'c'))
676 touch(os.path.join(self.localsrcdir, 'dir', 'd'))
677 os.makedirs(os.path.join(self.localsrcdir, 'dir', 'subdir'))
678 touch(os.path.join(self.localsrcdir, 'dir', 'subdir', 'e'))
679 touch(os.path.join(self.localsrcdir, r'backslash\x2dsystemd-unit.device'))
680 bb.process.run('tar cf archive.tar -C dir .', cwd=self.localsrcdir)
681 bb.process.run('tar czf archive.tar.gz -C dir .', cwd=self.localsrcdir)
682 bb.process.run('tar cjf archive.tar.bz2 -C dir .', cwd=self.localsrcdir)
683 self.d.setVar("FILESPATH", self.localsrcdir)
685 def fetchUnpack(self, uris): argument
686 fetcher = bb.fetch.Fetch(uris, self.d)
688 fetcher.unpack(self.unpackdir)
690 for root, dirs, files in os.walk(self.unpackdir):
692 flst.append(os.path.relpath(os.path.join(root, f), self.unpackdir))
696 def test_local(self): argument
697 tree = self.fetchUnpack(['file://a', 'file://dir/c'])
698 self.assertEqual(tree, ['a', 'dir/c'])
700 def test_local_backslash(self): argument
701 tree = self.fetchUnpack([r'file://backslash\x2dsystemd-unit.device'])
702 self.assertEqual(tree, [r'backslash\x2dsystemd-unit.device'])
704 def test_local_wildcard(self): argument
705 with self.assertRaises(bb.fetch2.ParameterError):
706 tree = self.fetchUnpack(['file://a', 'file://dir/*'])
708 def test_local_dir(self): argument
709 tree = self.fetchUnpack(['file://a', 'file://dir'])
710 self.assertEqual(tree, ['a', 'dir/c', 'dir/d', 'dir/subdir/e'])
712 def test_local_subdir(self): argument
713 tree = self.fetchUnpack(['file://dir/subdir'])
714 self.assertEqual(tree, ['dir/subdir/e'])
716 def test_local_subdir_file(self): argument
717 tree = self.fetchUnpack(['file://dir/subdir/e'])
718 self.assertEqual(tree, ['dir/subdir/e'])
720 def test_local_subdirparam(self): argument
721 tree = self.fetchUnpack(['file://a;subdir=bar', 'file://dir;subdir=foo/moo'])
722 self.assertEqual(tree, ['bar/a', 'foo/moo/dir/c', 'foo/moo/dir/d', 'foo/moo/dir/subdir/e'])
724 def test_local_deepsubdirparam(self): argument
725 tree = self.fetchUnpack(['file://dir/subdir/e;subdir=bar'])
726 self.assertEqual(tree, ['bar/dir/subdir/e'])
728 def test_local_absolutedir(self): argument
731 tree = self.fetchUnpack(['file://a;subdir=%s' % os.path.join(self.unpackdir, 'bar')])
734 with self.assertRaises(bb.fetch2.UnpackError):
735 self.fetchUnpack(['file://a;subdir=/bin/sh'])
737 def test_local_striplevel(self): argument
738 tree = self.fetchUnpack(['file://archive.tar;subdir=bar;striplevel=1'])
739 self.assertEqual(tree, ['bar/c', 'bar/d', 'bar/subdir/e'])
741 def test_local_striplevel_gzip(self): argument
742 tree = self.fetchUnpack(['file://archive.tar.gz;subdir=bar;striplevel=1'])
743 self.assertEqual(tree, ['bar/c', 'bar/d', 'bar/subdir/e'])
745 def test_local_striplevel_bzip2(self): argument
746 tree = self.fetchUnpack(['file://archive.tar.bz2;subdir=bar;striplevel=1'])
747 self.assertEqual(tree, ['bar/c', 'bar/d', 'bar/subdir/e'])
749 def dummyGitTest(self, suffix): argument
751 src_dir = tempfile.mkdtemp(dir=self.tempdir,
753 self.gitdir = os.path.abspath(src_dir)
754 self.git_init()
755 self.git(['commit', '--allow-empty', '-m', 'Dummy commit'])
757 self.git(['checkout', '-b', 'my-devel'])
758 self.git(['commit', '--allow-empty', '-m', 'Dummy commit 2'])
759 orig_rev = self.git(['rev-parse', 'HEAD']).strip()
762 self.d.setVar("SRCREV", "AUTOINC")
763 self.d.setVar("__BBSEENSRCREV", "1")
764 url = "git://" + self.gitdir + ";branch=master;protocol=file;" + suffix
765 fetcher = bb.fetch.Fetch([url], self.d)
767 fetcher.unpack(self.unpackdir)
768 unpack_rev = self.git(['rev-parse', 'HEAD'],
769 cwd=os.path.join(self.unpackdir, 'git')).strip()
770 self.assertEqual(orig_rev, unpack_rev)
772 def test_local_gitfetch_usehead(self): argument
773 self.dummyGitTest("usehead=1")
775 def test_local_gitfetch_usehead_withname(self): argument
776 self.dummyGitTest("usehead=1;name=newName")
778 def test_local_gitfetch_shared(self): argument
779 self.dummyGitTest("usehead=1;name=sharedName")
780 alt = os.path.join(self.unpackdir, 'git/.git/objects/info/alternates')
781 self.assertTrue(os.path.exists(alt))
783 def test_local_gitfetch_noshared(self): argument
784 self.d.setVar('BB_GIT_NOSHARED', '1')
785 self.unpackdir += '_noshared'
786 self.dummyGitTest("usehead=1;name=noSharedName")
787 alt = os.path.join(self.unpackdir, 'git/.git/objects/info/alternates')
788 self.assertFalse(os.path.exists(alt))
791 def setUp(self): argument
794 self.d.setVar("BB_NO_NETWORK", "1")
796 def test_missing(self): argument
798 self.d.setVarFlag("SRC_URI", "md5sum", hashlib.md5(string).hexdigest())
799 self.d.setVarFlag("SRC_URI", "sha256sum", hashlib.sha256(string).hexdigest())
801 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
802 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
803 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/test-file.tar.gz"], self.d)
804 with self.assertRaises(bb.fetch2.NetworkAccess):
807 def test_valid_missing_donestamp(self): argument
810 with open(os.path.join(self.dldir, "test-file.tar.gz"), "wb") as f:
813 self.d.setVarFlag("SRC_URI", "md5sum", hashlib.md5(string).hexdigest())
814 self.d.setVarFlag("SRC_URI", "sha256sum", hashlib.sha256(string).hexdigest())
816 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
817 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
818 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/test-file.tar.gz"], self.d)
820 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
822 def test_invalid_missing_donestamp(self): argument
825 with open(os.path.join(self.dldir, "test-file.tar.gz"), "wb"):
828 self.d.setVarFlag("SRC_URI", "md5sum", hashlib.md5(string).hexdigest())
829 self.d.setVarFlag("SRC_URI", "sha256sum", hashlib.sha256(string).hexdigest())
831 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
832 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
833 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/test-file.tar.gz"], self.d)
834 with self.assertRaises(bb.fetch2.NetworkAccess):
837 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
839 def test_nochecksums_missing(self): argument
840 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
841 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
843 … fetcher = bb.fetch.Fetch(["ssh://invalid@invalid.yoctoproject.org/test-file.tar.gz"], self.d)
845 with self.assertRaises(bb.fetch2.NetworkAccess):
848 def test_nochecksums_missing_donestamp(self): argument
850 with open(os.path.join(self.dldir, "test-file.tar.gz"), "wb"):
853 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
854 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
856 … fetcher = bb.fetch.Fetch(["ssh://invalid@invalid.yoctoproject.org/test-file.tar.gz"], self.d)
858 with self.assertRaises(bb.fetch2.NetworkAccess):
861 def test_nochecksums_has_donestamp(self): argument
863 with open(os.path.join(self.dldir, "test-file.tar.gz"), "wb"):
865 with open(os.path.join(self.dldir, "test-file.tar.gz.done"), "wb"):
868 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
869 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
871 … fetcher = bb.fetch.Fetch(["ssh://invalid@invalid.yoctoproject.org/test-file.tar.gz"], self.d)
875 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
876 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
878 def test_nochecksums_missing_has_donestamp(self): argument
880 with open(os.path.join(self.dldir, "test-file.tar.gz.done"), "wb"):
883 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
884 self.assertTrue(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
886 … fetcher = bb.fetch.Fetch(["ssh://invalid@invalid.yoctoproject.org/test-file.tar.gz"], self.d)
887 with self.assertRaises(bb.fetch2.NetworkAccess):
890 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
891 self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))
895 def test_fetch(self): argument
896 …ake-1.0.tar.gz", "https://downloads.yoctoproject.org/releases/bitbake/bitbake-1.1.tar.gz"], self.d)
898 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
899 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.1.tar.gz"), 57892)
900 self.d.setVar("BB_NO_NETWORK", "1")
901 …ake-1.0.tar.gz", "https://downloads.yoctoproject.org/releases/bitbake/bitbake-1.1.tar.gz"], self.d)
903 fetcher.unpack(self.unpackdir)
904 self.assertEqual(len(os.listdir(self.unpackdir + "/bitbake-1.0/")), 9)
905 self.assertEqual(len(os.listdir(self.unpackdir + "/bitbake-1.1/")), 9)
908 def test_fetch_mirror(self): argument
909 self.d.setVar("MIRRORS", "http://.*/.* https://downloads.yoctoproject.org/releases/bitbake")
910 …r = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
912 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
915 def test_fetch_mirror_of_mirror(self): argument
916self.d.setVar("MIRRORS", "http://.*/.* http://invalid2.yoctoproject.org/ http://invalid2.yoctoproj…
917 …r = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
919 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
922 def test_fetch_file_mirror_of_mirror(self): argument
923self.d.setVar("MIRRORS", "http://.*/.* file:///some1where/ file:///some1where/.* file://some2where…
924 …r = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
925 os.mkdir(self.dldir + "/some2where")
927 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
930 def test_fetch_premirror(self): argument
931self.d.setVar("PREMIRRORS", "http://.*/.* https://downloads.yoctoproject.org/releases/bitbake")
932 …r = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
934 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
937 def test_fetch_specify_downloadfilename(self): argument
938 …toproject.org/releases/bitbake/bitbake-1.0.tar.gz;downloadfilename=bitbake-v1.0.0.tar.gz"], self.d)
940 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-v1.0.0.tar.gz"), 57749)
943 def test_fetch_premirror_specify_downloadfilename_regex_uri(self): argument
944self.d.setVar("PREMIRRORS", "http://.*/.* https://downloads.yoctoproject.org/releases/bitbake/")
945 …invalid.yoctoproject.org/releases/bitbake/1.0.tar.gz;downloadfilename=bitbake-1.0.tar.gz"], self.d)
947 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
951 def test_fetch_premirror_specify_downloadfilename_specific_uri(self): argument
952self.d.setVar("PREMIRRORS", "http://invalid.yoctoproject.org/releases/bitbake https://downloads.yo…
953 …invalid.yoctoproject.org/releases/bitbake/1.0.tar.gz;downloadfilename=bitbake-1.0.tar.gz"], self.d)
955 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
958 def test_fetch_premirror_use_downloadfilename_to_fetch(self): argument
960self.d.setVar("PREMIRRORS", "http://.*/.* https://downloads.yoctoproject.org/releases/bitbake")
961 …yoctoproject.org/releases/bitbake/bitbake-1.1.tar.gz;downloadfilename=bitbake-1.0.tar.gz"], self.d)
963 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
966 def gitfetcher(self, url1, url2): argument
967 def checkrevision(self, fetcher): argument
968 fetcher.unpack(self.unpackdir)
969 revision = self.git(['rev-parse', 'HEAD'],
970 cwd=os.path.join(self.unpackdir, 'git')).strip()
971 self.assertEqual(revision, "270a05b0b4ba0959fe0624d2a4885d7b70426da5")
973 self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "1")
974 self.d.setVar("SRCREV", "270a05b0b4ba0959fe0624d2a4885d7b70426da5")
975 fetcher = bb.fetch.Fetch([url1], self.d)
977 checkrevision(self, fetcher)
979 bb.utils.prunedir(self.dldir + "/git2/")
980 bb.utils.prunedir(self.unpackdir)
981 self.d.setVar("BB_NO_NETWORK", "1")
982 fetcher = bb.fetch.Fetch([url2], self.d)
984 checkrevision(self, fetcher)
987 def test_gitfetch(self): argument
989 self.gitfetcher(url1, url2)
992 def test_gitfetch_goodsrcrev(self): argument
995 self.gitfetcher(url1, url2)
998 def test_gitfetch_badsrcrev(self): argument
1001 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
1004 def test_gitfetch_tagandrev(self): argument
1007 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
1010 def test_gitfetch_usehead(self): argument
1011 # Since self.gitfetcher() sets SRCREV we expect this to override
1016 self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url)
1019 def test_gitfetch_usehead_withname(self): argument
1020 # Since self.gitfetcher() sets SRCREV we expect this to override
1025 self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url)
1028 …est_gitfetch_finds_local_tarball_for_mirrored_url_when_previous_downloaded_by_the_recipe_url(self): argument
1031self.d.setVar("PREMIRRORS", "git://someserver.org/bitbake git://git.openembedded.org/bitbake")
1032 self.gitfetcher(recipeurl, mirrorurl)
1035 def test_gitfetch_finds_local_tarball_when_previous_downloaded_from_a_premirror(self): argument
1037self.d.setVar("PREMIRRORS", "git://someserver.org/bitbake git://git.openembedded.org/bitbake")
1038 self.gitfetcher(recipeurl, recipeurl)
1041 def test_gitfetch_finds_local_repository_when_premirror_rewrites_the_recipe_url(self): argument
1044 self.sourcedir = self.unpackdir.replace("unpacked", "sourcemirror.git")
1045 os.chdir(self.tempdir)
1046 self.git(['clone', realurl, self.sourcedir], cwd=self.tempdir)
1047 self.d.setVar("PREMIRRORS", "%s git://%s;protocol=file" % (recipeurl, self.sourcedir))
1048 self.gitfetcher(recipeurl, recipeurl)
1051 def test_git_submodule(self): argument
1056 fetcher = bb.fetch.Fetch([url], self.d)
1059 os.chdir(os.path.dirname(self.unpackdir))
1060 fetcher.unpack(self.unpackdir)
1062 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
1063 self.assertTrue(os.path.exists(repo_path), msg='Unpacked repository missing')
1064self.assertTrue(os.path.exists(os.path.join(repo_path, 'bitbake')), msg='bitbake submodule missing…
1065self.assertFalse(os.path.exists(os.path.join(repo_path, 'na')), msg='uninitialized submodule prese…
1069self.assertTrue(os.path.exists(os.path.join(repo_path, 'bitbake-gitsm-test1', 'bitbake')), msg='su…
1072 def test_git_submodule_dbus_broker(self): argument
1076 fetcher = bb.fetch.Fetch([url], self.d)
1079 os.chdir(os.path.dirname(self.unpackdir))
1080 fetcher.unpack(self.unpackdir)
1082 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
1083self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-dvar/config')),…
1084self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-list/config')),…
1085self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-rbtree/config')…
1086self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-sundry/config')…
1087self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-utf8/config')),…
1090 def test_git_submodule_CLI11(self): argument
1092 fetcher = bb.fetch.Fetch([url], self.d)
1095 os.chdir(os.path.dirname(self.unpackdir))
1096 fetcher.unpack(self.unpackdir)
1098 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
1099self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/googletest/config')), …
1100self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/json/config')), msg='M…
1101self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/sanitizers/config')), …
1104 def test_git_submodule_update_CLI11(self): argument
1107 fetcher = bb.fetch.Fetch([url], self.d)
1112 fetcher = bb.fetch.Fetch([url], self.d)
1115 os.chdir(os.path.dirname(self.unpackdir))
1116 fetcher.unpack(self.unpackdir)
1118 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
1119self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/googletest/config')), …
1120self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/json/config')), msg='M…
1121self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/sanitizers/config')), …
1124 def test_git_submodule_aktualizr(self): argument
1126 fetcher = bb.fetch.Fetch([url], self.d)
1129 os.chdir(os.path.dirname(self.unpackdir))
1130 fetcher.unpack(self.unpackdir)
1132 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
1133self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/partial/extern/isotp-c/config…
1134self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/partial/extern/isotp-c/module…
1135self.assertTrue(os.path.exists(os.path.join(repo_path, 'partial/extern/isotp-c/deps/bitfield-c/.gi…
1136self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/tests/tuf-test-vectors/config…
1137self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/third_party/googletest/config…
1138self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/third_party/HdrHistogram_c/co…
1141 def test_git_submodule_iotedge(self): argument
1146 fetcher = bb.fetch.Fetch([url], self.d)
1149 os.chdir(os.path.dirname(self.unpackdir))
1150 fetcher.unpack(self.unpackdir)
1152 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
1154self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-sha…
1155self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-sha…
1156self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-sha…
1157self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-sha…
1158self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-sha…
1159self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-sha…
1160self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/…
1161self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/…
1162self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/…
1163self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/…
1164self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/…
1165self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/…
1166self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/…
1180 def setUp(self): argument
1183 super(SVNTest, self).setUp()
1186 src_dir = tempfile.mkdtemp(dir=self.tempdir,
1192 repo_dir = tempfile.mkdtemp(dir=self.tempdir,
1197 self.repo_url = "file://%s/project" % repo_dir
1198 …cess.run("svn import --non-interactive -m 'Initial import' %s %s/trunk" % (src_dir, self.repo_url),
1201 bb.process.run("svn co %s svnfetch_co" % self.repo_url, cwd=self.tempdir)
1204 cwd=os.path.join(self.tempdir, 'svnfetch_co', 'trunk'))
1206 cwd=os.path.join(self.tempdir, 'svnfetch_co', 'trunk'))
1208 self.src_dir = src_dir
1209 self.repo_dir = repo_dir
1212 def tearDown(self): argument
1213 os.chdir(self.origdir)
1215 print("Not cleaning up %s. Please remove manually." % self.tempdir)
1217 bb.utils.prunedir(self.tempdir)
1221 def test_noexternal_svn(self): argument
1223 url = "svn://%s;module=trunk;protocol=file;rev=2" % self.repo_url.replace('file://', '')
1224 fetcher = bb.fetch.Fetch([url], self.d)
1226 os.chdir(os.path.dirname(self.unpackdir))
1227 fetcher.unpack(self.unpackdir)
1229 self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk')), msg="Missing trunk")
1230self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk', 'README.md')), msg="Missing c…
1231self.assertFalse(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk')), msg="Externa…
1232self.assertFalse(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk', 'README')), ms…
1235 def test_external_svn(self): argument
1237 …url = "svn://%s;module=trunk;protocol=file;externals=allowed;rev=2" % self.repo_url.replace('file:…
1238 fetcher = bb.fetch.Fetch([url], self.d)
1240 os.chdir(os.path.dirname(self.unpackdir))
1241 fetcher.unpack(self.unpackdir)
1243 self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk')), msg="Missing trunk")
1244self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk', 'README.md')), msg="Missing c…
1245self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk')), msg="External…
1246self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk', 'README')), msg…
1249 def test_trusted_network(self): argument
1252 self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org someserver.org server2.org server3.org")
1253 self.assertTrue(bb.fetch.trusted_network(self.d, url))
1255 def test_wild_trusted_network(self): argument
1258 self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org")
1259 self.assertTrue(bb.fetch.trusted_network(self.d, url))
1261 def test_prefix_wild_trusted_network(self): argument
1264 self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org")
1265 self.assertTrue(bb.fetch.trusted_network(self.d, url))
1267 def test_two_prefix_wild_trusted_network(self): argument
1270 self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org")
1271 self.assertTrue(bb.fetch.trusted_network(self.d, url))
1273 def test_port_trusted_network(self): argument
1276 self.d.setVar("BB_ALLOWED_NETWORKS", "someserver.org")
1277 self.assertTrue(bb.fetch.trusted_network(self.d, url))
1279 def test_untrusted_network(self): argument
1282 self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org server2.org server3.org")
1283 self.assertFalse(bb.fetch.trusted_network(self.d, url))
1285 def test_wild_untrusted_network(self): argument
1288 self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org server2.org server3.org")
1289 self.assertFalse(bb.fetch.trusted_network(self.d, url))
1307 def test_decodeurl(self): argument
1308 for k, v in self.decodedata.items():
1310 self.assertEqual(result, v)
1312 def test_encodeurl(self): argument
1313 for k, v in self.datatable.items():
1315 self.assertEqual(result, k)
1405 def test_git_latest_versionstring(self): argument
1406 for k, v in self.test_git_uris.items():
1407 self.d.setVar("PN", k[0])
1408 self.d.setVar("SRCREV", k[2])
1409 self.d.setVar("UPSTREAM_CHECK_GITTAGREGEX", k[3])
1410 ud = bb.fetch2.FetchData(k[1], self.d)
1411 pupver= ud.method.latest_versionstring(ud, self.d)
1413 self.assertTrue(verstring, msg="Could not find upstream version for %s" % k[0])
1415self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring))
1417 def test_wget_latest_versionstring(self): argument
1423 for k, v in self.test_wget_uris.items():
1424 self.d.setVar("PN", k[0])
1428 self.d.setVar("UPSTREAM_CHECK_URI", checkuri)
1429 self.d.setVar("UPSTREAM_CHECK_REGEX", k[3])
1431 ud = bb.fetch2.FetchData(url, self.d)
1432 pupver = ud.method.latest_versionstring(ud, self.d)
1434 self.assertTrue(verstring, msg="Could not find upstream version for %s" % k[0])
1436self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring))
1455 def test_wget_checkstatus(self): argument
1456 fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d)
1457 for u in self.test_wget_uris:
1458 with self.subTest(url=u):
1461 ret = m.checkstatus(fetch, ud, self.d)
1462 self.assertTrue(ret, msg="URI %s, can't check status" % (u))
1465 def test_wget_checkstatus_connection_cache(self): argument
1469 fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d,
1472 for u in self.test_wget_uris:
1473 with self.subTest(url=u):
1476 ret = m.checkstatus(fetch, ud, self.d)
1477 self.assertTrue(ret, msg="URI %s, can't check status" % (u))
1483 def setUp(self): argument
1484 FetcherTest.setUp(self)
1485 self.gitdir = os.path.join(self.tempdir, 'gitshallow')
1486 bb.utils.mkdirhier(self.gitdir)
1487 self.git_init()
1489 def assertRefs(self, expected_refs): argument
1490 actual_refs = self.git(['for-each-ref', '--format=%(refname)']).splitlines()
1491 full_expected = self.git(['rev-parse', '--symbolic-full-name'] + expected_refs).splitlines()
1492 self.assertEqual(sorted(full_expected), sorted(actual_refs))
1494 def assertRevCount(self, expected_count, args=None): argument
1497 revs = self.git(['rev-list'] + args)
1499self.assertEqual(expected_count, actual_count, msg='Object count `%d` is not the expected `%d`' % …
1501 def make_shallow(self, args=None): argument
1504 return bb.process.run([bb.fetch2.git.Git.make_shallow_path] + args, cwd=self.gitdir)
1506 def add_empty_file(self, path, msg=None): argument
1509 open(os.path.join(self.gitdir, path), 'w').close()
1510 self.git(['add', path])
1511 self.git(['commit', '-m', msg, path])
1513 def test_make_shallow_single_branch_no_merge(self): argument
1514 self.add_empty_file('a')
1515 self.add_empty_file('b')
1516 self.assertRevCount(2)
1517 self.make_shallow()
1518 self.assertRevCount(1)
1520 def test_make_shallow_single_branch_one_merge(self): argument
1521 self.add_empty_file('a')
1522 self.add_empty_file('b')
1523 self.git('checkout -b a_branch')
1524 self.add_empty_file('c')
1525 self.git('checkout master')
1526 self.add_empty_file('d')
1527 self.git('merge --no-ff --no-edit a_branch')
1528 self.git('branch -d a_branch')
1529 self.add_empty_file('e')
1530 self.assertRevCount(6)
1531 self.make_shallow(['HEAD~2'])
1532 self.assertRevCount(5)
1534 def test_make_shallow_at_merge(self): argument
1535 self.add_empty_file('a')
1536 self.git('checkout -b a_branch')
1537 self.add_empty_file('b')
1538 self.git('checkout master')
1539 self.git('merge --no-ff --no-edit a_branch')
1540 self.git('branch -d a_branch')
1541 self.assertRevCount(3)
1542 self.make_shallow()
1543 self.assertRevCount(1)
1545 def test_make_shallow_annotated_tag(self): argument
1546 self.add_empty_file('a')
1547 self.add_empty_file('b')
1548 self.git('tag -a -m a_tag a_tag')
1549 self.assertRevCount(2)
1550 self.make_shallow(['a_tag'])
1551 self.assertRevCount(1)
1553 def test_make_shallow_multi_ref(self): argument
1554 self.add_empty_file('a')
1555 self.add_empty_file('b')
1556 self.git('checkout -b a_branch')
1557 self.add_empty_file('c')
1558 self.git('checkout master')
1559 self.add_empty_file('d')
1560 self.git('checkout -b a_branch_2')
1561 self.add_empty_file('a_tag')
1562 self.git('tag a_tag')
1563 self.git('checkout master')
1564 self.git('branch -D a_branch_2')
1565 self.add_empty_file('e')
1566 self.assertRevCount(6, ['--all'])
1567 self.make_shallow()
1568 self.assertRevCount(5, ['--all'])
1570 def test_make_shallow_multi_ref_trim(self): argument
1571 self.add_empty_file('a')
1572 self.git('checkout -b a_branch')
1573 self.add_empty_file('c')
1574 self.git('checkout master')
1575 self.assertRevCount(1)
1576 self.assertRevCount(2, ['--all'])
1577 self.assertRefs(['master', 'a_branch'])
1578 self.make_shallow(['-r', 'master', 'HEAD'])
1579 self.assertRevCount(1, ['--all'])
1580 self.assertRefs(['master'])
1582 def test_make_shallow_noop(self): argument
1583 self.add_empty_file('a')
1584 self.assertRevCount(1)
1585 self.make_shallow()
1586 self.assertRevCount(1)
1589 def test_make_shallow_bitbake(self): argument
1590 self.git('remote add origin https://github.com/openembedded/bitbake')
1591 self.git('fetch --tags origin')
1592 orig_revs = len(self.git('rev-list --all').splitlines())
1593 self.make_shallow(['refs/tags/1.10.0'])
1594 self.assertRevCount(orig_revs - 1746, ['--all'])
1597 def setUp(self): argument
1598 FetcherTest.setUp(self)
1599 self.gitdir = os.path.join(self.tempdir, 'git')
1600 self.srcdir = os.path.join(self.tempdir, 'gitsource')
1602 bb.utils.mkdirhier(self.srcdir)
1603 self.git_init(cwd=self.srcdir)
1604 self.d.setVar('WORKDIR', self.tempdir)
1605 self.d.setVar('S', self.gitdir)
1606 self.d.delVar('PREMIRRORS')
1607 self.d.delVar('MIRRORS')
1609 uri = 'git://%s;protocol=file;subdir=${S};branch=master' % self.srcdir
1610 self.d.setVar('SRC_URI', uri)
1611 self.d.setVar('SRCREV', '${AUTOREV}')
1612 self.d.setVar('AUTOREV', '${@bb.fetch2.get_autorev(d)}')
1614 self.d.setVar('BB_GIT_SHALLOW', '1')
1615 self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '0')
1616 self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '1')
1617 self.d.setVar("__BBSEENSRCREV", "1")
1619 def assertRefs(self, expected_refs, cwd=None): argument
1621 cwd = self.gitdir
1622 actual_refs = self.git(['for-each-ref', '--format=%(refname)'], cwd=cwd).splitlines()
1623 …full_expected = self.git(['rev-parse', '--symbolic-full-name'] + expected_refs, cwd=cwd).splitline…
1624 self.assertEqual(sorted(set(full_expected)), sorted(set(actual_refs)))
1626 def assertRevCount(self, expected_count, args=None, cwd=None): argument
1630 cwd = self.gitdir
1631 revs = self.git(['rev-list'] + args, cwd=cwd)
1633self.assertEqual(expected_count, actual_count, msg='Object count `%d` is not the expected `%d`' % …
1635 def add_empty_file(self, path, cwd=None, msg=None): argument
1639 cwd = self.srcdir
1641 self.git(['add', path], cwd)
1642 self.git(['commit', '-m', msg, path], cwd)
1644 def fetch(self, uri=None): argument
1646 uris = self.d.getVar('SRC_URI').split()
1648 d = self.d
1650 d = self.d.createCopy()
1660 def fetch_and_unpack(self, uri=None): argument
1661 fetcher, ud = self.fetch(uri)
1662 fetcher.unpack(self.d.getVar('WORKDIR'))
1663 assert os.path.exists(self.d.getVar('S'))
1666 def fetch_shallow(self, uri=None, disabled=False, keepclone=False): argument
1668 fetcher, ud = self.fetch_and_unpack(uri)
1673 assert os.path.exists(os.path.join(self.dldir, ud.mirrortarballs[0]))
1676 bb.utils.remove(self.gitdir, recurse=True)
1683 fetcher, ud = self.fetch_and_unpack(uri)
1685 …sert os.path.exists(os.path.join(self.gitdir, '.git', 'shallow')), 'Unpacked git repository at %s …
1687 …rt not os.path.exists(os.path.join(self.gitdir, '.git', 'shallow')), 'Unpacked git repository at %…
1690 def test_shallow_disabled(self): argument
1691 self.add_empty_file('a')
1692 self.add_empty_file('b')
1693 self.assertRevCount(2, cwd=self.srcdir)
1695 self.d.setVar('BB_GIT_SHALLOW', '0')
1696 self.fetch_shallow(disabled=True)
1697 self.assertRevCount(2)
1699 def test_shallow_nobranch(self): argument
1700 self.add_empty_file('a')
1701 self.add_empty_file('b')
1702 self.assertRevCount(2, cwd=self.srcdir)
1704 srcrev = self.git('rev-parse HEAD', cwd=self.srcdir).strip()
1705 self.d.setVar('SRCREV', srcrev)
1706 uri = self.d.getVar('SRC_URI').split()[0]
1709 self.fetch_shallow(uri)
1710 self.assertRevCount(1)
1714 self.assertRefs(['refs/shallow/default'])
1716 def test_shallow_default_depth_1(self): argument
1718 self.add_empty_file('a')
1719 self.add_empty_file('b')
1720 self.assertRevCount(2, cwd=self.srcdir)
1722 self.fetch_shallow()
1723 self.assertRevCount(1)
1725 def test_shallow_depth_0_disables(self): argument
1726 self.add_empty_file('a')
1727 self.add_empty_file('b')
1728 self.assertRevCount(2, cwd=self.srcdir)
1730 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
1731 self.fetch_shallow(disabled=True)
1732 self.assertRevCount(2)
1734 def test_shallow_depth_default_override(self): argument
1735 self.add_empty_file('a')
1736 self.add_empty_file('b')
1737 self.assertRevCount(2, cwd=self.srcdir)
1739 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '2')
1740 self.d.setVar('BB_GIT_SHALLOW_DEPTH_default', '1')
1741 self.fetch_shallow()
1742 self.assertRevCount(1)
1744 def test_shallow_depth_default_override_disable(self): argument
1745 self.add_empty_file('a')
1746 self.add_empty_file('b')
1747 self.add_empty_file('c')
1748 self.assertRevCount(3, cwd=self.srcdir)
1750 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
1751 self.d.setVar('BB_GIT_SHALLOW_DEPTH_default', '2')
1752 self.fetch_shallow()
1753 self.assertRevCount(2)
1755 def test_current_shallow_out_of_date_clone(self): argument
1757 self.add_empty_file('a')
1758 self.add_empty_file('b')
1759 self.add_empty_file('c')
1760 self.assertRevCount(3, cwd=self.srcdir)
1763 fetcher, ud = self.fetch()
1766 self.git('update-ref refs/heads/master refs/heads/master~1', cwd=ud.clonedir)
1767 self.assertRevCount(2, cwd=ud.clonedir)
1770 bb.utils.remove(self.gitdir, recurse=True)
1771 fetcher, ud = self.fetch()
1772 fetcher.unpack(self.d.getVar('WORKDIR'))
1773 self.assertRevCount(1)
1775 def test_shallow_single_branch_no_merge(self): argument
1776 self.add_empty_file('a')
1777 self.add_empty_file('b')
1778 self.assertRevCount(2, cwd=self.srcdir)
1780 self.fetch_shallow()
1781 self.assertRevCount(1)
1782 assert os.path.exists(os.path.join(self.gitdir, 'a'))
1783 assert os.path.exists(os.path.join(self.gitdir, 'b'))
1785 def test_shallow_no_dangling(self): argument
1786 self.add_empty_file('a')
1787 self.add_empty_file('b')
1788 self.assertRevCount(2, cwd=self.srcdir)
1790 self.fetch_shallow()
1791 self.assertRevCount(1)
1792 assert not self.git('fsck --dangling')
1794 def test_shallow_srcrev_branch_truncation(self): argument
1795 self.add_empty_file('a')
1796 self.add_empty_file('b')
1797 b_commit = self.git('rev-parse HEAD', cwd=self.srcdir).rstrip()
1798 self.add_empty_file('c')
1799 self.assertRevCount(3, cwd=self.srcdir)
1801 self.d.setVar('SRCREV', b_commit)
1802 self.fetch_shallow()
1805 self.assertRevCount(1, ['--all'])
1806 self.assertEqual(self.git('rev-parse HEAD').strip(), b_commit)
1807 assert os.path.exists(os.path.join(self.gitdir, 'a'))
1808 assert os.path.exists(os.path.join(self.gitdir, 'b'))
1809 assert not os.path.exists(os.path.join(self.gitdir, 'c'))
1811 def test_shallow_ref_pruning(self): argument
1812 self.add_empty_file('a')
1813 self.add_empty_file('b')
1814 self.git('branch a_branch', cwd=self.srcdir)
1815 self.assertRefs(['master', 'a_branch'], cwd=self.srcdir)
1816 self.assertRevCount(2, cwd=self.srcdir)
1818 self.fetch_shallow()
1820 self.assertRefs(['master', 'origin/master'])
1821 self.assertRevCount(1)
1823 def test_shallow_submodules(self): argument
1824 self.add_empty_file('a')
1825 self.add_empty_file('b')
1827 smdir = os.path.join(self.tempdir, 'gitsubmodule')
1829 self.git_init(cwd=smdir)
1831 self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir)
1832self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
1833 self.add_empty_file('asub', cwd=smdir)
1834 self.add_empty_file('bsub', cwd=smdir)
1836 self.git('submodule init', cwd=self.srcdir)
1837 self.git('-c protocol.file.allow=always submodule add file://%s' % smdir, cwd=self.srcdir)
1838 self.git('submodule update', cwd=self.srcdir)
1839 self.git('commit -m submodule -a', cwd=self.srcdir)
1841 uri = 'gitsm://%s;protocol=file;subdir=${S};branch=master' % self.srcdir
1842 fetcher, ud = self.fetch_shallow(uri)
1845 self.assertRevCount(1)
1848 assert os.listdir(os.path.join(self.gitdir, 'gitsubmodule'))
1851 self.assertRevCount(1, cwd=os.path.join(self.gitdir, 'gitsubmodule'))
1853 def test_shallow_submodule_mirrors(self): argument
1854 self.add_empty_file('a')
1855 self.add_empty_file('b')
1857 smdir = os.path.join(self.tempdir, 'gitsubmodule')
1859 self.git_init(cwd=smdir)
1861 self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir)
1862self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
1863 self.add_empty_file('asub', cwd=smdir)
1864 self.add_empty_file('bsub', cwd=smdir)
1866 self.git('submodule init', cwd=self.srcdir)
1867 self.git('-c protocol.file.allow=always submodule add file://%s' % smdir, cwd=self.srcdir)
1868 self.git('submodule update', cwd=self.srcdir)
1869 self.git('commit -m submodule -a', cwd=self.srcdir)
1871 uri = 'gitsm://%s;protocol=file;subdir=${S}' % self.srcdir
1874 fetcher, ud = self.fetch(uri)
1877 mirrordir = os.path.join(self.tempdir, 'mirror')
1878 bb.utils.rename(self.dldir, mirrordir)
1879 self.d.setVar('PREMIRRORS', 'gitsm://.*/.* file://%s/' % mirrordir)
1882 bb.utils.remove(self.dldir, recurse=True)
1883 bb.utils.remove(self.gitdir, recurse=True)
1884 self.fetch_and_unpack(uri)
1887 self.assertRevCount(1)
1890 assert os.listdir(os.path.join(self.gitdir, 'gitsubmodule'))
1893 self.assertRevCount(1, cwd=os.path.join(self.gitdir, 'gitsubmodule'))
1896 def test_shallow_annex(self): argument
1897 self.add_empty_file('a')
1898 self.add_empty_file('b')
1899 self.git('annex init', cwd=self.srcdir)
1900 open(os.path.join(self.srcdir, 'c'), 'w').close()
1901 self.git('annex add c', cwd=self.srcdir)
1902 self.git('commit --author "Foo Bar <foo@bar>" -m annex-c -a', cwd=self.srcdir)
1903 bb.process.run('chmod u+w -R %s' % self.srcdir)
1905 uri = 'gitannex://%s;protocol=file;subdir=${S};branch=master' % self.srcdir
1906 fetcher, ud = self.fetch_shallow(uri)
1908 self.assertRevCount(1)
1909 …assert './.git/annex/' in bb.process.run('tar -tzf %s' % os.path.join(self.dldir, ud.mirrortarball…
1910 assert os.path.exists(os.path.join(self.gitdir, 'c'))
1912 def test_shallow_multi_one_uri(self): argument
1914 self.add_empty_file('a')
1915 self.add_empty_file('b')
1916 self.git('checkout -b a_branch', cwd=self.srcdir)
1917 self.add_empty_file('c')
1918 self.add_empty_file('d')
1919 self.git('checkout master', cwd=self.srcdir)
1920 self.git('tag v0.0 a_branch', cwd=self.srcdir)
1921 self.add_empty_file('e')
1922 self.git('merge --no-ff --no-edit a_branch', cwd=self.srcdir)
1923 self.add_empty_file('f')
1924 self.assertRevCount(7, cwd=self.srcdir)
1926 uri = self.d.getVar('SRC_URI').split()[0]
1929 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
1930 self.d.setVar('BB_GIT_SHALLOW_REVS', 'v0.0')
1931 self.d.setVar('SRCREV_master', '${AUTOREV}')
1932 self.d.setVar('SRCREV_a_branch', '${AUTOREV}')
1934 self.fetch_shallow(uri)
1936 self.assertRevCount(5)
1937 self.assertRefs(['master', 'origin/master', 'origin/a_branch'])
1939 def test_shallow_multi_one_uri_depths(self): argument
1941 self.add_empty_file('a')
1942 self.add_empty_file('b')
1943 self.git('checkout -b a_branch', cwd=self.srcdir)
1944 self.add_empty_file('c')
1945 self.add_empty_file('d')
1946 self.git('checkout master', cwd=self.srcdir)
1947 self.add_empty_file('e')
1948 self.git('merge --no-ff --no-edit a_branch', cwd=self.srcdir)
1949 self.add_empty_file('f')
1950 self.assertRevCount(7, cwd=self.srcdir)
1952 uri = self.d.getVar('SRC_URI').split()[0]
1955 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
1956 self.d.setVar('BB_GIT_SHALLOW_DEPTH_master', '3')
1957 self.d.setVar('BB_GIT_SHALLOW_DEPTH_a_branch', '1')
1958 self.d.setVar('SRCREV_master', '${AUTOREV}')
1959 self.d.setVar('SRCREV_a_branch', '${AUTOREV}')
1961 self.fetch_shallow(uri)
1963 self.assertRevCount(4, ['--all'])
1964 self.assertRefs(['master', 'origin/master', 'origin/a_branch'])
1966 def test_shallow_clone_preferred_over_shallow(self): argument
1967 self.add_empty_file('a')
1968 self.add_empty_file('b')
1971 fetcher, ud = self.fetch()
1972 assert os.path.exists(os.path.join(self.dldir, ud.mirrortarballs[0]))
1975 bb.utils.remove(self.gitdir, recurse=True)
1976 fetcher, ud = self.fetch_and_unpack()
1979 self.assertRevCount(2)
1980 assert not os.path.exists(os.path.join(self.gitdir, '.git', 'shallow'))
1982 def test_shallow_mirrors(self): argument
1983 self.add_empty_file('a')
1984 self.add_empty_file('b')
1987 fetcher, ud = self.fetch()
1989 assert os.path.exists(os.path.join(self.dldir, mirrortarball))
1992 mirrordir = os.path.join(self.tempdir, 'mirror')
1994 self.d.setVar('PREMIRRORS', 'git://.*/.* file://%s/' % mirrordir)
1996 bb.utils.rename(os.path.join(self.dldir, mirrortarball),
2000 bb.utils.remove(self.dldir, recurse=True)
2001 bb.utils.remove(self.gitdir, recurse=True)
2002 self.fetch_and_unpack()
2003 self.assertRevCount(1)
2005 def test_shallow_invalid_depth(self): argument
2006 self.add_empty_file('a')
2007 self.add_empty_file('b')
2009 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '-12')
2010 with self.assertRaises(bb.fetch2.FetchError):
2011 self.fetch()
2013 def test_shallow_invalid_depth_default(self): argument
2014 self.add_empty_file('a')
2015 self.add_empty_file('b')
2017 self.d.setVar('BB_GIT_SHALLOW_DEPTH_default', '-12')
2018 with self.assertRaises(bb.fetch2.FetchError):
2019 self.fetch()
2021 def test_shallow_extra_refs(self): argument
2022 self.add_empty_file('a')
2023 self.add_empty_file('b')
2024 self.git('branch a_branch', cwd=self.srcdir)
2025 self.assertRefs(['master', 'a_branch'], cwd=self.srcdir)
2026 self.assertRevCount(2, cwd=self.srcdir)
2028 self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/heads/a_branch')
2029 self.fetch_shallow()
2031 self.assertRefs(['master', 'origin/master', 'origin/a_branch'])
2032 self.assertRevCount(1)
2034 def test_shallow_extra_refs_wildcard(self): argument
2035 self.add_empty_file('a')
2036 self.add_empty_file('b')
2037 self.git('branch a_branch', cwd=self.srcdir)
2038 self.git('tag v1.0', cwd=self.srcdir)
2039 self.assertRefs(['master', 'a_branch', 'v1.0'], cwd=self.srcdir)
2040 self.assertRevCount(2, cwd=self.srcdir)
2042 self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/tags/*')
2043 self.fetch_shallow()
2045 self.assertRefs(['master', 'origin/master', 'v1.0'])
2046 self.assertRevCount(1)
2048 def test_shallow_missing_extra_refs(self): argument
2049 self.add_empty_file('a')
2050 self.add_empty_file('b')
2052 self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/heads/foo')
2053 with self.assertRaises(bb.fetch2.FetchError):
2054 self.fetch()
2056 def test_shallow_missing_extra_refs_wildcard(self): argument
2057 self.add_empty_file('a')
2058 self.add_empty_file('b')
2060 self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/tags/*')
2061 self.fetch()
2063 def test_shallow_remove_revs(self): argument
2065 self.add_empty_file('a')
2066 self.add_empty_file('b')
2067 self.git('checkout -b a_branch', cwd=self.srcdir)
2068 self.add_empty_file('c')
2069 self.add_empty_file('d')
2070 self.git('checkout master', cwd=self.srcdir)
2071 self.git('tag v0.0 a_branch', cwd=self.srcdir)
2072 self.add_empty_file('e')
2073 self.git('merge --no-ff --no-edit a_branch', cwd=self.srcdir)
2074 self.git('branch -d a_branch', cwd=self.srcdir)
2075 self.add_empty_file('f')
2076 self.assertRevCount(7, cwd=self.srcdir)
2078 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
2079 self.d.setVar('BB_GIT_SHALLOW_REVS', 'v0.0')
2081 self.fetch_shallow()
2083 self.assertRevCount(5)
2085 def test_shallow_invalid_revs(self): argument
2086 self.add_empty_file('a')
2087 self.add_empty_file('b')
2089 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
2090 self.d.setVar('BB_GIT_SHALLOW_REVS', 'v0.0')
2092 with self.assertRaises(bb.fetch2.FetchError):
2093 self.fetch()
2095 def test_shallow_fetch_missing_revs(self): argument
2096 self.add_empty_file('a')
2097 self.add_empty_file('b')
2098 fetcher, ud = self.fetch(self.d.getVar('SRC_URI'))
2099 self.git('tag v0.0 master', cwd=self.srcdir)
2100 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
2101 self.d.setVar('BB_GIT_SHALLOW_REVS', 'v0.0')
2102 self.fetch_shallow()
2104 def test_shallow_fetch_missing_revs_fails(self): argument
2105 self.add_empty_file('a')
2106 self.add_empty_file('b')
2107 fetcher, ud = self.fetch(self.d.getVar('SRC_URI'))
2108 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
2109 self.d.setVar('BB_GIT_SHALLOW_REVS', 'v0.0')
2111 …with self.assertRaises(bb.fetch2.FetchError), self.assertLogs("BitBake.Fetcher", level="ERROR") as…
2112 self.fetch_shallow()
2113 self.assertIn("Unable to find revision v0.0 even from upstream", cm.output[0])
2116 def test_bitbake(self): argument
2117self.git('remote add --mirror=fetch origin https://github.com/openembedded/bitbake', cwd=self.srcd…
2118 self.git('config core.bare true', cwd=self.srcdir)
2119 self.git('fetch', cwd=self.srcdir)
2121 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
2124 self.d.setVar('BB_GIT_SHALLOW_REVS', '1.10.0')
2126 self.fetch_shallow()
2129 orig_revs = len(self.git('rev-list master', cwd=self.srcdir).splitlines())
2130 revs = len(self.git('rev-list master').splitlines())
2131 self.assertNotEqual(orig_revs, revs)
2132 self.assertRefs(['master', 'origin/master'])
2133 self.assertRevCount(orig_revs - 1758)
2135 def test_that_unpack_throws_an_error_when_the_git_clone_nor_shallow_tarball_exist(self): argument
2136 self.add_empty_file('a')
2137 fetcher, ud = self.fetch()
2138 bb.utils.remove(self.gitdir, recurse=True)
2139 bb.utils.remove(self.dldir, recurse=True)
2141 with self.assertRaises(bb.fetch2.UnpackError) as context:
2142 fetcher.unpack(self.d.getVar('WORKDIR'))
2144 self.assertIn("No up to date source found", context.exception.msg)
2145 self.assertIn("clone directory not available or not up to date", context.exception.msg)
2148 … def test_that_unpack_does_work_when_using_git_shallow_tarball_but_tarball_is_not_available(self): argument
2149 self.d.setVar('SRCREV', 'e5939ff608b95cdd4d0ab0e1935781ab9a276ac0')
2150 self.d.setVar('BB_GIT_SHALLOW', '1')
2151 self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '1')
2152 fetcher = bb.fetch.Fetch(["git://git.yoctoproject.org/fstests;branch=master"], self.d)
2155 bb.utils.remove(self.dldir + "/*.tar.gz")
2156 fetcher.unpack(self.unpackdir)
2158 dir = os.listdir(self.unpackdir + "/git/")
2159 self.assertIn("fstests.doap", dir)
2162 def setUp(self): argument
2163 FetcherTest.setUp(self)
2165 self.gitdir = os.path.join(self.tempdir, 'git')
2166 self.srcdir = os.path.join(self.tempdir, 'gitsource')
2168 self.d.setVar('WORKDIR', self.tempdir)
2169 self.d.setVar('S', self.gitdir)
2170 self.d.delVar('PREMIRRORS')
2171 self.d.delVar('MIRRORS')
2173 self.d.setVar('SRCREV', '${AUTOREV}')
2174 self.d.setVar('AUTOREV', '${@bb.fetch2.get_autorev(d)}')
2175 self.d.setVar("__BBSEENSRCREV", "1")
2177 bb.utils.mkdirhier(self.srcdir)
2178 self.git_init(cwd=self.srcdir)
2179 with open(os.path.join(self.srcdir, '.gitattributes'), 'wt') as attrs:
2181 self.git(['add', '.gitattributes'], cwd=self.srcdir)
2182 self.git(['commit', '-m', "attributes", '.gitattributes'], cwd=self.srcdir)
2184 def fetch(self, uri=None, download=True): argument
2185 uris = self.d.getVar('SRC_URI').split()
2187 d = self.d
2195 def test_lfs_enabled(self): argument
2198 uri = 'git://%s;protocol=file;lfs=1;branch=master' % self.srcdir
2199 self.d.setVar('SRC_URI', uri)
2203 fetcher, ud = self.fetch(uri=None, download=False)
2204 self.assertIsNotNone(ud.method._find_git_lfs)
2208 if ud.method._find_git_lfs(self.d):
2210 shutil.rmtree(self.gitdir, ignore_errors=True)
2211 fetcher.unpack(self.d.getVar('WORKDIR'))
2214 with self.assertRaises(bb.fetch2.FetchError):
2217 shutil.rmtree(self.gitdir, ignore_errors=True)
2218 fetcher.unpack(self.d.getVar('WORKDIR'))
2220 def test_lfs_disabled(self): argument
2223 uri = 'git://%s;protocol=file;lfs=0;branch=master' % self.srcdir
2224 self.d.setVar('SRC_URI', uri)
2227 # done by self.fetch() to occur here. The point of this test case
2230 fetcher, ud = self.fetch()
2231 self.assertIsNotNone(ud.method._find_git_lfs)
2237 shutil.rmtree(self.gitdir, ignore_errors=True)
2238 fetcher.unpack(self.d.getVar('WORKDIR'))
2242 shutil.rmtree(self.gitdir, ignore_errors=True)
2243 fetcher.unpack(self.d.getVar('WORKDIR'))
2259 def test_urls(self): argument
2262 self.d.setVar('SRCREV', '82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40')
2264 for test_git_url, ref in self.test_git_urls.items():
2266 fetcher = bb.fetch.Fetch([test_git_url], self.d)
2269 self.assertEqual(ud.url, ref['url'])
2270 self.assertEqual(ud.path, ref['path'])
2271 self.assertEqual(ud.localfile, os.path.join(self.dldir, "git2", ref['gitsrcname']))
2272 self.assertEqual(ud.localpath, os.path.join(self.dldir, "git2", ref['gitsrcname']))
2273self.assertEqual(ud.lockfile, os.path.join(self.dldir, "git2", ref['gitsrcname'] + '.lock'))
2274 self.assertEqual(ud.clonedir, os.path.join(self.dldir, "git2", ref['gitsrcname']))
2275self.assertEqual(ud.fullmirror, os.path.join(self.dldir, "git2_" + ref['gitsrcname'] + '.tar.gz'))
2279 def test_crate_url(self): argument
2282 self.d.setVar('SRC_URI', uri)
2284 uris = self.d.getVar('SRC_URI').split()
2285 d = self.d
2287 fetcher = bb.fetch2.Fetch(uris, self.d)
2289 fetcher.unpack(self.tempdir)
2290 self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked'])
2291self.assertEqual(sorted(os.listdir(self.tempdir + "/download")), ['glob-0.2.11.crate', 'glob-0.2.1…
2292self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/glob-0.2.11/.cargo-checksum.jso…
2293 self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/glob-0.2.11/src/lib.rs"))
2296 def test_crate_url_multi(self): argument
2299 self.d.setVar('SRC_URI', uri)
2301 uris = self.d.getVar('SRC_URI').split()
2302 d = self.d
2304 fetcher = bb.fetch2.Fetch(uris, self.d)
2306 fetcher.unpack(self.tempdir)
2307 self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked'])
2308self.assertEqual(sorted(os.listdir(self.tempdir + "/download")), ['glob-0.2.11.crate', 'glob-0.2.1…
2309self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/glob-0.2.11/.cargo-checksum.jso…
2310 self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/glob-0.2.11/src/lib.rs"))
2311self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.jso…
2312 self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs"))
2323 def test_npm(self): argument
2325 fetcher = bb.fetch.Fetch([url], self.d)
2328 self.assertTrue(os.path.exists(ud.localpath))
2329 self.assertTrue(os.path.exists(ud.localpath + '.done'))
2330 self.assertTrue(os.path.exists(ud.resolvefile))
2331 fetcher.unpack(self.unpackdir)
2332 unpackdir = os.path.join(self.unpackdir, 'npm')
2333 self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json')))
2337 def test_npm_bad_checksum(self): argument
2340 fetcher = bb.fetch.Fetch([url], self.d)
2343 self.assertTrue(os.path.exists(ud.localpath))
2351 self.assertTrue(os.path.exists(ud.localpath + '_bad-checksum_' + badsum))
2352 self.assertTrue(os.path.exists(ud.localpath))
2356 def test_npm_premirrors(self): argument
2359 fetcher = bb.fetch.Fetch([url], self.d)
2362 self.assertTrue(os.path.exists(ud.localpath))
2365 mirrordir = os.path.join(self.tempdir, 'mirror')
2366 bb.utils.rename(self.dldir, mirrordir)
2367 os.mkdir(self.dldir)
2370 self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/npm2' % mirrordir)
2371 self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
2374 self.assertFalse(os.path.exists(ud.localpath))
2379 fetcher = bb.fetch.Fetch([url], self.d)
2382 self.assertTrue(os.path.exists(ud.localpath))
2386 def test_npm_premirrors_with_specified_filename(self): argument
2389 fetcher = bb.fetch.Fetch([url], self.d)
2392 self.assertTrue(os.path.exists(ud.localpath))
2394 mirrordir = os.path.join(self.tempdir, 'mirror')
2398 self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s' % mirrorfilename)
2399 self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
2401 self.assertFalse(os.path.exists(ud.localpath))
2403 self.assertTrue(os.path.exists(ud.localpath))
2407 def test_npm_mirrors(self): argument
2410 fetcher = bb.fetch.Fetch([url], self.d)
2413 self.assertTrue(os.path.exists(ud.localpath))
2415 mirrordir = os.path.join(self.tempdir, 'mirror')
2418 self.d.setVar('MIRRORS', 'https?$://.*/.* file://%s/' % mirrordir)
2427 self.assertFalse(os.path.exists(ud.localpath))
2429 self.assertTrue(os.path.exists(ud.localpath))
2433 def test_npm_destsuffix_downloadfilename(self): argument
2435 fetcher = bb.fetch.Fetch([url], self.d)
2437 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'foo-bar.tgz')))
2438 fetcher.unpack(self.unpackdir)
2439 unpackdir = os.path.join(self.unpackdir, 'foo', 'bar')
2440 self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json')))
2442 def test_npm_no_network_no_tarball(self): argument
2444 self.d.setVar('BB_NO_NETWORK', '1')
2445 fetcher = bb.fetch.Fetch([url], self.d)
2446 with self.assertRaises(bb.fetch2.NetworkAccess):
2451 def test_npm_no_network_with_tarball(self): argument
2454 fetcher = bb.fetch.Fetch([url], self.d)
2457 self.d.setVar('BB_NO_NETWORK', '1')
2460 fetcher.unpack(self.unpackdir)
2461 unpackdir = os.path.join(self.unpackdir, 'npm')
2462 self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json')))
2466 def test_npm_registry_alternate(self): argument
2468 fetcher = bb.fetch.Fetch([url], self.d)
2470 fetcher.unpack(self.unpackdir)
2471 unpackdir = os.path.join(self.unpackdir, 'npm')
2472 self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json')))
2476 def test_npm_version_latest(self): argument
2478 fetcher = bb.fetch.Fetch([url], self.d)
2480 fetcher.unpack(self.unpackdir)
2481 unpackdir = os.path.join(self.unpackdir, 'npm')
2482 self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json')))
2486 def test_npm_registry_invalid(self): argument
2488 fetcher = bb.fetch.Fetch([url], self.d)
2489 with self.assertRaises(bb.fetch2.FetchError):
2494 def test_npm_package_invalid(self): argument
2496 fetcher = bb.fetch.Fetch([url], self.d)
2497 with self.assertRaises(bb.fetch2.FetchError):
2502 def test_npm_version_invalid(self): argument
2504 with self.assertRaises(bb.fetch2.ParameterError):
2505 fetcher = bb.fetch.Fetch([url], self.d)
2509 def test_npm_registry_none(self): argument
2511 with self.assertRaises(bb.fetch2.MalformedUrl):
2512 fetcher = bb.fetch.Fetch([url], self.d)
2516 def test_npm_package_none(self): argument
2518 with self.assertRaises(bb.fetch2.MissingParameterError):
2519 fetcher = bb.fetch.Fetch([url], self.d)
2523 def test_npm_version_none(self): argument
2525 with self.assertRaises(bb.fetch2.MissingParameterError):
2526 fetcher = bb.fetch.Fetch([url], self.d)
2528 def create_shrinkwrap_file(self, data): argument
2530 datadir = os.path.join(self.tempdir, 'data')
2536 self.sdir = os.path.join(self.unpackdir, 'S')
2537 self.d.setVar('S', self.sdir)
2542 def test_npmsw(self): argument
2543 swfile = self.create_shrinkwrap_file({
2564 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2566 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz')))
2567 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz')))
2568self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'github.com.jshttp.cookie.git')))
2569 fetcher.unpack(self.unpackdir)
2570 self.assertTrue(os.path.exists(os.path.join(self.sdir, 'npm-shrinkwrap.json')))
2571self.assertTrue(os.path.exists(os.path.join(self.sdir, 'node_modules', 'array-flatten', 'package.j…
2572self.assertTrue(os.path.exists(os.path.join(self.sdir, 'node_modules', 'array-flatten', 'node_modu…
2573self.assertTrue(os.path.exists(os.path.join(self.sdir, 'node_modules', 'array-flatten', 'node_modu…
2577 def test_npmsw_dev(self): argument
2578 swfile = self.create_shrinkwrap_file({
2594 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2596 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz')))
2597 self.assertFalse(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz')))
2599 fetcher = bb.fetch.Fetch(['npmsw://' + swfile + ';dev=1'], self.d)
2601 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz')))
2602 self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz')))
2606 def test_npmsw_destsuffix(self): argument
2607 swfile = self.create_shrinkwrap_file({
2616 fetcher = bb.fetch.Fetch(['npmsw://' + swfile + ';destsuffix=foo/bar'], self.d)
2618 fetcher.unpack(self.unpackdir)
2619self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'foo', 'bar', 'node_modules', 'array-f…
2621 def test_npmsw_no_network_no_tarball(self): argument
2622 swfile = self.create_shrinkwrap_file({
2631 self.d.setVar('BB_NO_NETWORK', '1')
2632 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2633 with self.assertRaises(bb.fetch2.NetworkAccess):
2638 def test_npmsw_no_network_with_tarball(self): argument
2640 … fetcher = bb.fetch.Fetch(['npm://registry.npmjs.org;package=array-flatten;version=1.1.1'], self.d)
2643 self.d.setVar('BB_NO_NETWORK', '1')
2645 swfile = self.create_shrinkwrap_file({
2654 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2656 fetcher.unpack(self.unpackdir)
2657self.assertTrue(os.path.exists(os.path.join(self.sdir, 'node_modules', 'array-flatten', 'package.j…
2661 def test_npmsw_npm_reusability(self): argument
2663 swfile = self.create_shrinkwrap_file({
2672 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2675 self.d.setVar('BB_NO_NETWORK', '1')
2677 … fetcher = bb.fetch.Fetch(['npm://registry.npmjs.org;package=array-flatten;version=1.1.1'], self.d)
2679 fetcher.unpack(self.unpackdir)
2680 self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'npm', 'package.json')))
2684 def test_npmsw_bad_checksum(self): argument
2686 swfile = self.create_shrinkwrap_file({
2695 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2696 with self.assertRaises(bb.fetch2.FetchError):
2699 swfile = self.create_shrinkwrap_file({
2708 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2710 localpath = os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz')
2711 self.assertTrue(os.path.exists(localpath))
2719 self.assertTrue(os.path.exists(localpath + '_bad-checksum_' + badsum))
2720 self.assertTrue(os.path.exists(localpath))
2724 def test_npmsw_premirrors(self): argument
2726 … fetcher = bb.fetch.Fetch(['npm://registry.npmjs.org;package=array-flatten;version=1.1.1'], self.d)
2729 self.assertTrue(os.path.exists(ud.localpath))
2731 mirrordir = os.path.join(self.tempdir, 'mirror')
2734 self.d.setVar('PREMIRRORS', 'https?$://.*/.* file://%s/' % mirrordir)
2735 self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
2737 self.assertFalse(os.path.exists(ud.localpath))
2738 swfile = self.create_shrinkwrap_file({
2747 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2749 self.assertTrue(os.path.exists(ud.localpath))
2753 def test_npmsw_mirrors(self): argument
2755 … fetcher = bb.fetch.Fetch(['npm://registry.npmjs.org;package=array-flatten;version=1.1.1'], self.d)
2758 self.assertTrue(os.path.exists(ud.localpath))
2760 mirrordir = os.path.join(self.tempdir, 'mirror')
2763 self.d.setVar('MIRRORS', 'https?$://.*/.* file://%s/' % mirrordir)
2765 self.assertFalse(os.path.exists(ud.localpath))
2766 swfile = self.create_shrinkwrap_file({
2775 fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d)
2777 self.assertTrue(os.path.exists(ud.localpath))
2780 def setUp(self): argument
2781 super(GitSharedTest, self).setUp()
2782 self.recipe_url = "git://git.openembedded.org/bitbake;branch=master"
2783 self.d.setVar('SRCREV', '82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40')
2784 self.d.setVar("__BBSEENSRCREV", "1")
2787 def test_shared_unpack(self): argument
2788 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
2791 fetcher.unpack(self.unpackdir)
2792 alt = os.path.join(self.unpackdir, 'git/.git/objects/info/alternates')
2793 self.assertTrue(os.path.exists(alt))
2796 def test_noshared_unpack(self): argument
2797 self.d.setVar('BB_GIT_NOSHARED', '1')
2798 self.unpackdir += '_noshared'
2799 fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
2802 fetcher.unpack(self.unpackdir)
2803 alt = os.path.join(self.unpackdir, 'git/.git/objects/info/alternates')
2804 self.assertFalse(os.path.exists(alt))