1 |
commit: 41652a49cbd99ea129b36834faf5ba7508f3f617 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Sep 5 22:35:02 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 5 22:35:02 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=41652a49 |
7 |
|
8 |
tests/emerge: test egencache |
9 |
|
10 |
This tests --update in any case, and --update-use-local-desc only if |
11 |
python xml support is detected. |
12 |
|
13 |
--- |
14 |
bin/egencache | 11 +++----- |
15 |
pym/portage/tests/emerge/test_simple.py | 43 ++++++++++++++++++++++++------ |
16 |
2 files changed, 38 insertions(+), 16 deletions(-) |
17 |
|
18 |
diff --git a/bin/egencache b/bin/egencache |
19 |
index 53ae565..bf29474 100755 |
20 |
--- a/bin/egencache |
21 |
+++ b/bin/egencache |
22 |
@@ -772,8 +772,6 @@ def egencache_main(args): |
23 |
parser, options, atoms = parse_args(args) |
24 |
|
25 |
config_root = options.config_root |
26 |
- if config_root is None: |
27 |
- config_root = '/' |
28 |
|
29 |
# The calling environment is ignored, so the program is |
30 |
# completely controlled by commandline arguments. |
31 |
@@ -790,8 +788,10 @@ def egencache_main(args): |
32 |
if options.portdir is not None: |
33 |
env['PORTDIR'] = options.portdir |
34 |
|
35 |
+ eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX") |
36 |
+ |
37 |
settings = portage.config(config_root=config_root, |
38 |
- target_root='/', local_config=False, env=env) |
39 |
+ local_config=False, env=env, _eprefix=eprefix) |
40 |
|
41 |
default_opts = None |
42 |
if not options.ignore_default_opts: |
43 |
@@ -800,14 +800,11 @@ def egencache_main(args): |
44 |
if default_opts: |
45 |
parser, options, args = parse_args(default_opts + args) |
46 |
|
47 |
- if options.config_root is not None: |
48 |
- config_root = options.config_root |
49 |
- |
50 |
if options.cache_dir is not None: |
51 |
env['PORTAGE_DEPCACHEDIR'] = options.cache_dir |
52 |
|
53 |
settings = portage.config(config_root=config_root, |
54 |
- target_root='/', local_config=False, env=env) |
55 |
+ local_config=False, env=env, _eprefix=eprefix) |
56 |
|
57 |
if not options.update and not options.update_use_local_desc \ |
58 |
and not options.update_changelogs: |
59 |
|
60 |
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py |
61 |
index 20cfa8f..3f7a3be 100644 |
62 |
--- a/pym/portage/tests/emerge/test_simple.py |
63 |
+++ b/pym/portage/tests/emerge/test_simple.py |
64 |
@@ -7,7 +7,7 @@ import sys |
65 |
import portage |
66 |
from portage import os |
67 |
from portage import _unicode_decode |
68 |
-from portage.const import PORTAGE_BIN_PATH, PORTAGE_PYM_PATH |
69 |
+from portage.const import PORTAGE_BIN_PATH, PORTAGE_PYM_PATH, USER_CONFIG_PATH |
70 |
from portage.process import find_binary |
71 |
from portage.tests import TestCase |
72 |
from portage.tests.resolver.ResolverPlayground import ResolverPlayground |
73 |
@@ -15,6 +15,14 @@ from portage.util import ensure_dirs |
74 |
|
75 |
class SimpleEmergeTestCase(TestCase): |
76 |
|
77 |
+ def _have_python_xml(self): |
78 |
+ try: |
79 |
+ __import__("xml.etree.ElementTree") |
80 |
+ __import__("xml.parsers.expat").parsers.expat.ExpatError |
81 |
+ except (AttributeError, ImportError): |
82 |
+ return False |
83 |
+ return True |
84 |
+ |
85 |
def testSimple(self): |
86 |
|
87 |
debug = False |
88 |
@@ -111,6 +119,8 @@ src_install() { |
89 |
) |
90 |
|
91 |
portage_python = portage._python_interpreter |
92 |
+ egencache_cmd = (portage_python, "-Wd", |
93 |
+ os.path.join(PORTAGE_BIN_PATH, "egencache")) |
94 |
emerge_cmd = (portage_python, "-Wd", |
95 |
os.path.join(PORTAGE_BIN_PATH, "emerge")) |
96 |
emaint_cmd = (portage_python, "-Wd", |
97 |
@@ -118,7 +128,12 @@ src_install() { |
98 |
quickpkg_cmd = (portage_python, "-Wd", |
99 |
os.path.join(PORTAGE_BIN_PATH, "quickpkg")) |
100 |
|
101 |
+ egencache_extra_args = [] |
102 |
+ if self._have_python_xml(): |
103 |
+ egencache_extra_args.append("--update-use-local-desc") |
104 |
+ |
105 |
test_commands = ( |
106 |
+ egencache_cmd + ("--update",) + tuple(egencache_extra_args), |
107 |
emerge_cmd + ("--version",), |
108 |
emerge_cmd + ("--info",), |
109 |
emerge_cmd + ("--info", "--verbose"), |
110 |
@@ -149,8 +164,21 @@ src_install() { |
111 |
portage_tmpdir = os.path.join(eprefix, "var", "tmp", "portage") |
112 |
portdir = settings["PORTDIR"] |
113 |
profile_path = settings.profile_path |
114 |
+ user_config_dir = os.path.join(os.sep, eprefix, USER_CONFIG_PATH) |
115 |
var_cache_edb = os.path.join(eprefix, "var", "cache", "edb") |
116 |
|
117 |
+ features = [] |
118 |
+ features.append("metadata-transfer") |
119 |
+ if not portage.process.sandbox_capable: |
120 |
+ features.append("-sandbox") |
121 |
+ |
122 |
+ # Since egencache ignores settings from the calling environment, |
123 |
+ # configure it via make.conf. |
124 |
+ make_conf = ( |
125 |
+ "FEATURES=\"%s\"\n" % (" ".join(features),), |
126 |
+ "PORTDIR=\"%s\"\n" % (portdir,), |
127 |
+ ) |
128 |
+ |
129 |
path = os.environ.get("PATH") |
130 |
if path is not None and not path.strip(): |
131 |
path = None |
132 |
@@ -188,17 +216,11 @@ src_install() { |
133 |
"PORTAGE_PYTHON" : portage_python, |
134 |
"PORTAGE_TMPDIR" : portage_tmpdir, |
135 |
"PORTAGE_USERNAME" : os.environ["PORTAGE_USERNAME"], |
136 |
- "PORTDIR" : portdir, |
137 |
"PYTHONPATH" : pythonpath, |
138 |
} |
139 |
|
140 |
- features = [] |
141 |
- if not portage.process.sandbox_capable: |
142 |
- features.append("-sandbox") |
143 |
- if features: |
144 |
- env["FEATURES"] = " ".join(features) |
145 |
- |
146 |
- dirs = [distdir, fake_bin, portage_tmpdir, var_cache_edb] |
147 |
+ dirs = [distdir, fake_bin, portage_tmpdir, |
148 |
+ user_config_dir, var_cache_edb] |
149 |
true_symlinks = ["chown", "chgrp"] |
150 |
true_binary = find_binary("true") |
151 |
self.assertEqual(true_binary is None, False, |
152 |
@@ -206,6 +228,9 @@ src_install() { |
153 |
try: |
154 |
for d in dirs: |
155 |
ensure_dirs(d) |
156 |
+ with open(os.path.join(user_config_dir, "make.conf"), 'w') as f: |
157 |
+ for line in make_conf: |
158 |
+ f.write(line) |
159 |
for x in true_symlinks: |
160 |
os.symlink(true_binary, os.path.join(fake_bin, x)) |
161 |
with open(os.path.join(var_cache_edb, "counter"), 'wb') as f: |