summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-09-05 15:35:02 -0700
committerZac Medico <zmedico@gentoo.org>2011-09-05 15:35:02 -0700
commit41652a49cbd99ea129b36834faf5ba7508f3f617 (patch)
tree1d931dfedd3b433e338c35a06cdacb2648f5ffab /pym
parentc39406adff994d6483a08edf59c9bf6b84191f68 (diff)
downloadportage-41652a49cbd99ea129b36834faf5ba7508f3f617.tar.gz
portage-41652a49cbd99ea129b36834faf5ba7508f3f617.tar.bz2
portage-41652a49cbd99ea129b36834faf5ba7508f3f617.zip
tests/emerge: test egencache
This tests --update in any case, and --update-use-local-desc only if python xml support is detected.
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/tests/emerge/test_simple.py43
1 files changed, 34 insertions, 9 deletions
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: