Use PORTAGE_REPOSITORIES in test suite.
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Sat, 13 Jul 2013 09:49:57 +0000 (11:49 +0200)
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Sat, 13 Jul 2013 09:49:57 +0000 (11:49 +0200)
pym/portage/__init__.py
pym/portage/tests/dbapi/test_portdb_cache.py
pym/portage/tests/ebuild/test_config.py
pym/portage/tests/emerge/test_emerge_slot_abi.py
pym/portage/tests/emerge/test_simple.py
pym/portage/tests/repoman/test_simple.py
pym/portage/tests/resolver/ResolverPlayground.py

index 35bf1520f030d2c106e12ffeeffaa11a4f8ba53b..1fb35bb96b799f320c47ae376e36f0e9584340af 100644 (file)
@@ -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'):
index e5270c52671a61e353ab55849cc1b7273c5fa70a..98439629d1ec9cee93b1595134a8fbcefb896f03 100644 (file)
@@ -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,
                }
 
index 38e8b6edb469370e072c7ed3747f690e26180429..cee2435a78125e67a728e974b0c77a54194c930a 100644 (file)
@@ -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()
index 949caf3111d21bea956559bd98213c0100c2bd31..7d8426b9b991eb0f1390d3a4805c7f100e1292af 100644 (file)
@@ -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,
                }
 
index a74e646adbdf68c0a06919ee9ef7f07cd61bb19a..ad02384a823c70f6c419d983da1b9f11d6a1a8d8 100644 (file)
@@ -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,
index 83227a9c5f2d9220c67c4b16177ce82eb96218cf..fbc75023d3f644d2625cfa8911805a5e9046751a 100644 (file)
@@ -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,
                }
 
index d2ceb320af6def85883cbb6b5cbb2876b796b81d..a311c08fee8be8e931b5685e959ed0546a8ee221 100644 (file)
@@ -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():