Test non-empty thin manifests.
authorZac Medico <zmedico@gentoo.org>
Thu, 15 Sep 2011 04:15:39 +0000 (21:15 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 15 Sep 2011 04:15:39 +0000 (21:15 -0700)
pym/portage/tests/ebuild/test_config.py
pym/portage/tests/resolver/ResolverPlayground.py

index 3d0be19e4dfc7ff08fc07e59b12f1ca54f04791d..f4869c6b14ccab19faf6498ad7167d6b56a64549 100644 (file)
@@ -200,9 +200,17 @@ class ConfigTestCase(TestCase):
 
        def testManifest(self):
 
+               distfiles = {
+                       'B-2.tar.bz2': b'binary\0content',
+                       'C-2.zip': b'binary\0content',
+                       'C-2.tar.bz2': b'binary\0content',
+               }
+
                ebuilds = {
                        "dev-libs/A-1::old_repo": { },
                        "dev-libs/A-2::new_repo": { },
+                       "dev-libs/B-2::new_repo": {"SRC_URI" : "B-2.tar.bz2"},
+                       "dev-libs/C-2::new_repo": {"SRC_URI" : "C-2.zip C-2.tar.bz2"},
                }
 
                repo_configs = {
@@ -226,11 +234,22 @@ class ConfigTestCase(TestCase):
                                        success = True),
                )
 
-               playground = ResolverPlayground(ebuilds=ebuilds, repo_configs=repo_configs)
+               playground = ResolverPlayground(ebuilds=ebuilds,
+                       repo_configs=repo_configs, distfiles=distfiles)
 
                new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "A", "Manifest")
                self.assertEqual(os.path.exists(new_manifest_file), False)
 
+               new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "B", "Manifest")
+               f = open(new_manifest_file)
+               self.assertEqual(len(list(f)), 1)
+               f.close()
+
+               new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "C", "Manifest")
+               f = open(new_manifest_file)
+               self.assertEqual(len(list(f)), 2)
+               f.close()
+
                old_manifest_file = os.path.join(playground.repo_dirs["old_repo"], "dev-libs", "A", "Manifest")
                f = open(old_manifest_file)
                self.assertEqual(len(list(f)), 1)
index e22121db7bbff23b74ce98bce4a9bf79f5826b57..5fb64cfbbb334f2925d0bb1b800d4656f356a944 100644 (file)
@@ -57,7 +57,7 @@ class ResolverPlayground(object):
 """
 
        def __init__(self, ebuilds={}, installed={}, profile={}, repo_configs={}, \
-               user_config={}, sets={}, world=[], debug=False):
+               user_config={}, sets={}, world=[], distfiles={}, debug=False):
                """
                ebuilds: cpv -> metadata mapping simulating available ebuilds. 
                installed: cpv -> metadata mapping simulating installed packages.
@@ -68,6 +68,7 @@ class ResolverPlayground(object):
                self.root = "/"
                self.eprefix = tempfile.mkdtemp()
                self.eroot = self.root + self.eprefix.lstrip(os.sep) + os.sep
+               self.distdir = os.path.join(self.eroot, "var", "portage", "distfiles")
                self.portdir = os.path.join(self.eroot, "usr/portage")
                self.vdbdir = os.path.join(self.eroot, "var/db/pkg")
                os.makedirs(self.portdir)
@@ -80,6 +81,7 @@ class ResolverPlayground(object):
                #Make sure the main repo is always created
                self._get_repo_dir("test_repo")
 
+               self._create_distfiles(distfiles)
                self._create_ebuilds(ebuilds)
                self._create_installed(installed)
                self._create_profile(ebuilds, installed, profile, repo_configs, user_config, sets)
@@ -116,6 +118,12 @@ class ResolverPlayground(object):
 
                return self.repo_dirs[repo]
 
+       def _create_distfiles(self, distfiles):
+               os.makedirs(self.distdir)
+               for k, v in distfiles.items():
+                       with open(os.path.join(self.distdir, k), 'wb') as f:
+                               f.write(v)
+
        def _create_ebuilds(self, ebuilds):
                for cpv in ebuilds:
                        a = Atom("=" + cpv, allow_repo=True)
@@ -132,6 +140,7 @@ class ResolverPlayground(object):
                        slot = metadata.pop("SLOT", 0)
                        keywords = metadata.pop("KEYWORDS", "x86")
                        homepage = metadata.pop("HOMEPAGE", None)
+                       src_uri = metadata.pop("SRC_URI", None)
                        iuse = metadata.pop("IUSE", "")
                        depend = metadata.pop("DEPEND", "")
                        rdepend = metadata.pop("RDEPEND", None)
@@ -158,6 +167,8 @@ class ResolverPlayground(object):
                                f.write('DESCRIPTION="%s"\n' % desc)
                        if homepage is not None:
                                f.write('HOMEPAGE="%s"\n' % homepage)
+                       if src_uri is not None:
+                               f.write('SRC_URI="%s"\n' % src_uri)
                        f.write('LICENSE="' + str(lic) + '"\n')
                        f.write('PROPERTIES="' + str(properties) + '"\n')
                        f.write('SLOT="' + str(slot) + '"\n')
@@ -454,6 +465,7 @@ class ResolverPlayground(object):
 
                env = {
                        "ACCEPT_KEYWORDS": "x86",
+                       "DISTDIR" : self.distdir,
                        "PORTDIR": self.portdir,
                        "PORTDIR_OVERLAY": " ".join(portdir_overlay),
                        'PORTAGE_TMPDIR'       : os.path.join(self.eroot, 'var/tmp'),