From: Zac Medico Date: Mon, 5 Sep 2011 22:35:02 +0000 (-0700) Subject: tests/emerge: test egencache X-Git-Tag: v2.2.0_alpha54~7 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=41652a49cbd99ea129b36834faf5ba7508f3f617;p=portage.git tests/emerge: test egencache This tests --update in any case, and --update-use-local-desc only if python xml support is detected. --- diff --git a/bin/egencache b/bin/egencache index 53ae56582..bf29474ef 100755 --- a/bin/egencache +++ b/bin/egencache @@ -772,8 +772,6 @@ def egencache_main(args): parser, options, atoms = parse_args(args) config_root = options.config_root - if config_root is None: - config_root = '/' # The calling environment is ignored, so the program is # completely controlled by commandline arguments. @@ -790,8 +788,10 @@ def egencache_main(args): if options.portdir is not None: env['PORTDIR'] = options.portdir + eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX") + settings = portage.config(config_root=config_root, - target_root='/', local_config=False, env=env) + local_config=False, env=env, _eprefix=eprefix) default_opts = None if not options.ignore_default_opts: @@ -800,14 +800,11 @@ def egencache_main(args): if default_opts: parser, options, args = parse_args(default_opts + args) - if options.config_root is not None: - config_root = options.config_root - if options.cache_dir is not None: env['PORTAGE_DEPCACHEDIR'] = options.cache_dir settings = portage.config(config_root=config_root, - target_root='/', local_config=False, env=env) + local_config=False, env=env, _eprefix=eprefix) if not options.update and not options.update_use_local_desc \ and not options.update_changelogs: diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py index 20cfa8f59..3f7a3bebe 100644 --- a/pym/portage/tests/emerge/test_simple.py +++ b/pym/portage/tests/emerge/test_simple.py @@ -7,7 +7,7 @@ import sys import portage from portage import os from portage import _unicode_decode -from portage.const import PORTAGE_BIN_PATH, PORTAGE_PYM_PATH +from portage.const import PORTAGE_BIN_PATH, PORTAGE_PYM_PATH, USER_CONFIG_PATH from portage.process import find_binary from portage.tests import TestCase from portage.tests.resolver.ResolverPlayground import ResolverPlayground @@ -15,6 +15,14 @@ from portage.util import ensure_dirs class SimpleEmergeTestCase(TestCase): + def _have_python_xml(self): + try: + __import__("xml.etree.ElementTree") + __import__("xml.parsers.expat").parsers.expat.ExpatError + except (AttributeError, ImportError): + return False + return True + def testSimple(self): debug = False @@ -111,6 +119,8 @@ src_install() { ) portage_python = portage._python_interpreter + egencache_cmd = (portage_python, "-Wd", + os.path.join(PORTAGE_BIN_PATH, "egencache")) emerge_cmd = (portage_python, "-Wd", os.path.join(PORTAGE_BIN_PATH, "emerge")) emaint_cmd = (portage_python, "-Wd", @@ -118,7 +128,12 @@ src_install() { quickpkg_cmd = (portage_python, "-Wd", os.path.join(PORTAGE_BIN_PATH, "quickpkg")) + egencache_extra_args = [] + if self._have_python_xml(): + egencache_extra_args.append("--update-use-local-desc") + test_commands = ( + egencache_cmd + ("--update",) + tuple(egencache_extra_args), emerge_cmd + ("--version",), emerge_cmd + ("--info",), emerge_cmd + ("--info", "--verbose"), @@ -149,8 +164,21 @@ src_install() { portage_tmpdir = os.path.join(eprefix, "var", "tmp", "portage") portdir = settings["PORTDIR"] profile_path = settings.profile_path + user_config_dir = os.path.join(os.sep, eprefix, USER_CONFIG_PATH) var_cache_edb = os.path.join(eprefix, "var", "cache", "edb") + features = [] + features.append("metadata-transfer") + if not portage.process.sandbox_capable: + features.append("-sandbox") + + # Since egencache ignores settings from the calling environment, + # configure it via make.conf. + make_conf = ( + "FEATURES=\"%s\"\n" % (" ".join(features),), + "PORTDIR=\"%s\"\n" % (portdir,), + ) + path = os.environ.get("PATH") if path is not None and not path.strip(): path = None @@ -188,17 +216,11 @@ src_install() { "PORTAGE_PYTHON" : portage_python, "PORTAGE_TMPDIR" : portage_tmpdir, "PORTAGE_USERNAME" : os.environ["PORTAGE_USERNAME"], - "PORTDIR" : portdir, "PYTHONPATH" : pythonpath, } - features = [] - if not portage.process.sandbox_capable: - features.append("-sandbox") - if features: - env["FEATURES"] = " ".join(features) - - dirs = [distdir, fake_bin, portage_tmpdir, var_cache_edb] + dirs = [distdir, fake_bin, portage_tmpdir, + user_config_dir, var_cache_edb] true_symlinks = ["chown", "chgrp"] true_binary = find_binary("true") self.assertEqual(true_binary is None, False, @@ -206,6 +228,9 @@ src_install() { try: for d in dirs: ensure_dirs(d) + with open(os.path.join(user_config_dir, "make.conf"), 'w') as f: + for line in make_conf: + f.write(line) for x in true_symlinks: os.symlink(true_binary, os.path.join(fake_bin, x)) with open(os.path.join(var_cache_edb, "counter"), 'wb') as f: