From c7f2b8a6878bda5b9251af3aa5164f57fe0627fc Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 13 Jul 2013 11:49:57 +0200 Subject: [PATCH] Use PORTAGE_REPOSITORIES in test suite. --- pym/portage/__init__.py | 2 +- pym/portage/tests/dbapi/test_portdb_cache.py | 5 ++- pym/portage/tests/ebuild/test_config.py | 14 ++++--- .../tests/emerge/test_emerge_slot_abi.py | 1 + pym/portage/tests/emerge/test_simple.py | 5 ++- pym/portage/tests/repoman/test_simple.py | 2 +- .../tests/resolver/ResolverPlayground.py | 39 +++++++------------ 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 35bf1520f..1fb35bb96 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -606,7 +606,7 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None, # environment to apply to the config that's associated # with ROOT != "/", so pass a nearly empty dict for the env parameter. clean_env = {} - for k in ('PATH', 'PORTAGE_GRPNAME', 'PORTAGE_USERNAME', + for k in ('PATH', 'PORTAGE_GRPNAME', 'PORTAGE_REPOSITORIES', 'PORTAGE_USERNAME', 'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'TERM', 'ftp_proxy', 'http_proxy', 'no_proxy', '__PORTAGE_TEST_HARDLINK_LOCKS'): diff --git a/pym/portage/tests/dbapi/test_portdb_cache.py b/pym/portage/tests/dbapi/test_portdb_cache.py index e5270c526..98439629d 100644 --- a/pym/portage/tests/dbapi/test_portdb_cache.py +++ b/pym/portage/tests/dbapi/test_portdb_cache.py @@ -38,7 +38,9 @@ class PortdbCacheTestCase(TestCase): portage_python = portage._python_interpreter egencache_cmd = (portage_python, "-Wd", - os.path.join(PORTAGE_BIN_PATH, "egencache")) + os.path.join(PORTAGE_BIN_PATH, "egencache"), + "--repo", "test_repo", + "--repositories-configuration", settings.repositories.config_string()) python_cmd = (portage_python, "-Wd", "-c") test_commands = ( @@ -132,6 +134,7 @@ class PortdbCacheTestCase(TestCase): "PATH" : os.environ.get("PATH", ""), "PORTAGE_OVERRIDE_EPREFIX" : eprefix, "PORTAGE_PYTHON" : portage_python, + "PORTAGE_REPOSITORIES" : settings.repositories.config_string(), "PYTHONPATH" : pythonpath, } diff --git a/pym/portage/tests/ebuild/test_config.py b/pym/portage/tests/ebuild/test_config.py index 38e8b6edb..cee2435a7 100644 --- a/pym/portage/tests/ebuild/test_config.py +++ b/pym/portage/tests/ebuild/test_config.py @@ -1,4 +1,4 @@ -# Copyright 2010-2012 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import portage @@ -239,28 +239,30 @@ class ConfigTestCase(TestCase): playground = ResolverPlayground(ebuilds=ebuilds, repo_configs=repo_configs, distfiles=distfiles) + settings = playground.settings - new_repo_config = playground.settings.repositories.prepos['new_repo'] + new_repo_config = settings.repositories["new_repo"] + old_repo_config = settings.repositories["old_repo"] self.assertTrue(len(new_repo_config.masters) > 0, "new_repo has no default master") self.assertEqual(new_repo_config.masters[0].user_location, playground.portdir, "new_repo default master is not PORTDIR") self.assertEqual(new_repo_config.thin_manifest, True, "new_repo_config.thin_manifest != True") - new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "A", "Manifest") + new_manifest_file = os.path.join(new_repo_config.location, "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") + new_manifest_file = os.path.join(new_repo_config.location, "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") + new_manifest_file = os.path.join(new_repo_config.location, "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") + old_manifest_file = os.path.join(old_repo_config.location, "dev-libs", "A", "Manifest") f = open(old_manifest_file) self.assertEqual(len(list(f)), 1) f.close() diff --git a/pym/portage/tests/emerge/test_emerge_slot_abi.py b/pym/portage/tests/emerge/test_emerge_slot_abi.py index 949caf311..7d8426b9b 100644 --- a/pym/portage/tests/emerge/test_emerge_slot_abi.py +++ b/pym/portage/tests/emerge/test_emerge_slot_abi.py @@ -119,6 +119,7 @@ class SlotAbiEmergeTestCase(TestCase): "PORTAGE_OVERRIDE_EPREFIX" : eprefix, "PATH" : path, "PORTAGE_PYTHON" : portage_python, + "PORTAGE_REPOSITORIES" : settings.repositories.config_string(), "PYTHONPATH" : pythonpath, } diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py index a74e646ad..ad02384a8 100644 --- a/pym/portage/tests/emerge/test_simple.py +++ b/pym/portage/tests/emerge/test_simple.py @@ -179,7 +179,9 @@ pkg_preinst() { ebuild_cmd = (portage_python, "-Wd", os.path.join(PORTAGE_BIN_PATH, "ebuild")) egencache_cmd = (portage_python, "-Wd", - os.path.join(PORTAGE_BIN_PATH, "egencache")) + os.path.join(PORTAGE_BIN_PATH, "egencache"), + "--repo", "test_repo", + "--repositories-configuration", settings.repositories.config_string()) emerge_cmd = (portage_python, "-Wd", os.path.join(PORTAGE_BIN_PATH, "emerge")) emaint_cmd = (portage_python, "-Wd", @@ -337,6 +339,7 @@ pkg_preinst() { "PORTAGE_INST_GID" : str(portage.data.portage_gid), "PORTAGE_INST_UID" : str(portage.data.portage_uid), "PORTAGE_PYTHON" : portage_python, + "PORTAGE_REPOSITORIES" : settings.repositories.config_string(), "PORTAGE_TMPDIR" : portage_tmpdir, "PYTHONPATH" : pythonpath, "__PORTAGE_TEST_PATH_OVERRIDE" : fake_bin, diff --git a/pym/portage/tests/repoman/test_simple.py b/pym/portage/tests/repoman/test_simple.py index 83227a9c5..fbc75023d 100644 --- a/pym/portage/tests/repoman/test_simple.py +++ b/pym/portage/tests/repoman/test_simple.py @@ -228,7 +228,7 @@ class SimpleRepomanTestCase(TestCase): "PATH" : os.environ["PATH"], "PORTAGE_GRPNAME" : os.environ["PORTAGE_GRPNAME"], "PORTAGE_USERNAME" : os.environ["PORTAGE_USERNAME"], - "PORTDIR" : test_repo_location, + "PORTAGE_REPOSITORIES" : settings.repositories.config_string(), "PYTHONPATH" : pythonpath, } diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index d2ceb320a..a311c08fe 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -83,7 +83,7 @@ class ResolverPlayground(object): if not debug: portage.util.noiselimit = -2 - self.repo_dirs = {} + self._repositories = {} #Make sure the main repo is always created self._get_repo_dir("test_repo") @@ -104,13 +104,14 @@ class ResolverPlayground(object): """ Create the repo directory if needed. """ - if repo not in self.repo_dirs: + if repo not in self._repositories: if repo == "test_repo": repo_path = self.portdir + self._repositories["DEFAULT"] = {"main-repo": repo} else: repo_path = os.path.join(self.eroot, "usr", "local", repo) - self.repo_dirs[repo] = repo_path + self._repositories[repo] = {"location": repo_path} profile_path = os.path.join(repo_path, "profiles") try: @@ -123,7 +124,7 @@ class ResolverPlayground(object): f.write("%s\n" % repo) f.close() - return self.repo_dirs[repo] + return self._repositories[repo]["location"] def _create_distfiles(self, distfiles): os.makedirs(self.distdir) @@ -255,9 +256,12 @@ class ResolverPlayground(object): except os.error: pass - for repo in self.repo_dirs: + for repo in self._repositories: + if repo == "DEFAULT": + continue + repo_dir = self._get_repo_dir(repo) - profile_dir = os.path.join(self._get_repo_dir(repo), "profiles") + profile_dir = os.path.join(repo_dir, "profiles") metadata_dir = os.path.join(repo_dir, "metadata") os.makedirs(metadata_dir) @@ -364,31 +368,14 @@ class ResolverPlayground(object): with open(os.path.join(metadata_dir, "metadata.xml"), 'w') as f: f.write(herds_xml) - # Write empty entries for each repository, in order to exercise - # RepoConfigLoader's repos.conf processing. - repos_conf_file = os.path.join(user_config_dir, "repos.conf") - f = open(repos_conf_file, "w") - for repo in sorted(self.repo_dirs.keys()): - f.write("[%s]\n" % repo) - f.write("\n") - f.close() - - portdir_overlay = [] - for repo_name in sorted(self.repo_dirs): - path = self.repo_dirs[repo_name] - if path != self.portdir: - portdir_overlay.append(path) - make_conf = { "ACCEPT_KEYWORDS": "x86", "CLEAN_DELAY": "0", "DISTDIR" : self.distdir, "EMERGE_WARNING_DELAY": "0", "PKGDIR": self.pkgdir, - "PORTDIR": self.portdir, "PORTAGE_INST_GID": str(portage.data.portage_gid), "PORTAGE_INST_UID": str(portage.data.portage_uid), - "PORTDIR_OVERLAY": " ".join("'%s'" % x for x in portdir_overlay), "PORTAGE_TMPDIR": os.path.join(self.eroot, 'var/tmp'), } @@ -484,7 +471,11 @@ class ResolverPlayground(object): if self.target_root != os.sep: create_trees_kwargs["target_root"] = self.target_root - trees = portage.create_trees(env={}, eprefix=self.eprefix, + env = { + "PORTAGE_REPOSITORIES": "\n".join("[%s]\n%s" % (repo_name, "\n".join("%s = %s" % (k, v) for k, v in repo_config.items())) for repo_name, repo_config in self._repositories.items()) + } + + trees = portage.create_trees(env=env, eprefix=self.eprefix, **create_trees_kwargs) for root, root_trees in trees.items(): -- 2.26.2