diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-09-14 21:15:39 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-09-14 21:15:39 -0700 |
commit | a5e7c15b03a9c6982f28ad2460261c98fe35889b (patch) | |
tree | 1a756663a71e923cda679962112741868f7190ec | |
parent | 30d598768326128d5e6c22983fb456eb1085cf7e (diff) | |
download | portage-a5e7c15b03a9c6982f28ad2460261c98fe35889b.tar.gz portage-a5e7c15b03a9c6982f28ad2460261c98fe35889b.tar.bz2 portage-a5e7c15b03a9c6982f28ad2460261c98fe35889b.zip |
Test non-empty thin manifests.
-rw-r--r-- | pym/portage/tests/ebuild/test_config.py | 21 | ||||
-rw-r--r-- | pym/portage/tests/resolver/ResolverPlayground.py | 14 |
2 files changed, 33 insertions, 2 deletions
diff --git a/pym/portage/tests/ebuild/test_config.py b/pym/portage/tests/ebuild/test_config.py index 3d0be19e4..f4869c6b1 100644 --- a/pym/portage/tests/ebuild/test_config.py +++ b/pym/portage/tests/ebuild/test_config.py @@ -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) diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index e22121db7..5fb64cfbb 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -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'), |