1 |
For packages matched by arguments, this option will pull in dependencies |
2 |
that are conditional on the "test" USE flag, even if FEATURES=test is not |
3 |
enabled for the matched packages. The state of the "test" USE flag is not |
4 |
affected by this option. It only changes the effective dependencies |
5 |
which are processed by the depgraph._add_pkg_deps method. |
6 |
|
7 |
X-Gentoo-Bug: 520652 |
8 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=520652 |
9 |
--- |
10 |
man/emerge.1 | 8 ++++- |
11 |
pym/_emerge/create_depgraph_params.py | 5 +++ |
12 |
pym/_emerge/depgraph.py | 23 ++++++++++-- |
13 |
pym/_emerge/main.py | 11 ++++++ |
14 |
pym/portage/tests/resolver/test_with_test_deps.py | 44 +++++++++++++++++++++++ |
15 |
5 files changed, 88 insertions(+), 3 deletions(-) |
16 |
create mode 100644 pym/portage/tests/resolver/test_with_test_deps.py |
17 |
|
18 |
diff --git a/man/emerge.1 b/man/emerge.1 |
19 |
index bbe71ac..a206e8e 100644 |
20 |
--- a/man/emerge.1 |
21 |
+++ b/man/emerge.1 |
22 |
@@ -1,4 +1,4 @@ |
23 |
-.TH "EMERGE" "1" "Oct 2014" "Portage VERSION" "Portage" |
24 |
+.TH "EMERGE" "1" "Nov 2014" "Portage VERSION" "Portage" |
25 |
.SH "NAME" |
26 |
emerge \- Command\-line interface to the Portage system |
27 |
.SH "SYNOPSIS" |
28 |
@@ -894,6 +894,12 @@ installation actions, meaning they will not be installed, and |
29 |
This setting can be added to |
30 |
\fBEMERGE_DEFAULT_OPTS\fR (see make.conf(5)) and later overridden via the |
31 |
command line. |
32 |
+.TP |
33 |
+.BR "\-\-with\-test\-deps [ y | n ]" |
34 |
+For packages matched by arguments, this option will pull in dependencies |
35 |
+that are conditional on the "test" USE flag, even if "test" is not |
36 |
+enabled in \fBFEATURES\fR for the matched packages. (see \fBmake.conf\fR(5) |
37 |
+for more information about \fBFEATURES\fR settings). |
38 |
.SH "ENVIRONMENT OPTIONS" |
39 |
.TP |
40 |
\fBEPREFIX\fR = \fI[path]\fR |
41 |
diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py |
42 |
index 225b792..6f74de7 100644 |
43 |
--- a/pym/_emerge/create_depgraph_params.py |
44 |
+++ b/pym/_emerge/create_depgraph_params.py |
45 |
@@ -21,6 +21,7 @@ def create_depgraph_params(myopts, myaction): |
46 |
# removal by the --depclean action as soon as possible |
47 |
# ignore_built_slot_operator_deps: ignore the slot/sub-slot := operator parts |
48 |
# of dependencies that have been recorded when packages where built |
49 |
+ # with_test_deps: pull in test deps for packages matched by arguments |
50 |
myparams = {"recurse" : True} |
51 |
|
52 |
bdeps = myopts.get("--with-bdeps") |
53 |
@@ -104,6 +105,10 @@ def create_depgraph_params(myopts, myaction): |
54 |
# other option like --update. |
55 |
myparams.pop("selective", None) |
56 |
|
57 |
+ with_test_deps = myopts.get("--with-test-deps") |
58 |
+ if with_test_deps is not None: |
59 |
+ myparams["with_test_deps"] = with_test_deps |
60 |
+ |
61 |
if '--debug' in myopts: |
62 |
writemsg_level('\n\nmyparams %s\n\n' % myparams, |
63 |
noiselevel=-1, level=logging.DEBUG) |
64 |
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py |
65 |
index 94eaed8..ddadb22 100644 |
66 |
--- a/pym/_emerge/depgraph.py |
67 |
+++ b/pym/_emerge/depgraph.py |
68 |
@@ -2691,6 +2691,19 @@ class depgraph(object): |
69 |
for k in Package._dep_keys: |
70 |
edepend[k] = metadata[k] |
71 |
|
72 |
+ with_test_deps = not removal_action and \ |
73 |
+ "with_test_deps" in \ |
74 |
+ self._dynamic_config.myparams and \ |
75 |
+ pkg.depth == 0 and \ |
76 |
+ "test" not in pkg.use.enabled and \ |
77 |
+ pkg.iuse.is_valid_flag("test") and \ |
78 |
+ self._is_argument(pkg) |
79 |
+ |
80 |
+ use_enabled = self._pkg_use_enabled(pkg) |
81 |
+ if with_test_deps: |
82 |
+ use_enabled = set(use_enabled) |
83 |
+ use_enabled.add("test") |
84 |
+ |
85 |
if not pkg.built and \ |
86 |
"--buildpkgonly" in self._frozen_config.myopts and \ |
87 |
"deep" not in self._dynamic_config.myparams: |
88 |
@@ -2774,7 +2787,7 @@ class depgraph(object): |
89 |
|
90 |
try: |
91 |
dep_string = portage.dep.use_reduce(dep_string, |
92 |
- uselist=self._pkg_use_enabled(pkg), |
93 |
+ uselist=use_enabled, |
94 |
is_valid_flag=pkg.iuse.is_valid_flag, |
95 |
opconvert=True, token_class=Atom, |
96 |
eapi=pkg.eapi) |
97 |
@@ -2789,7 +2802,7 @@ class depgraph(object): |
98 |
# practical to ignore this issue for installed packages. |
99 |
try: |
100 |
dep_string = portage.dep.use_reduce(dep_string, |
101 |
- uselist=self._pkg_use_enabled(pkg), |
102 |
+ uselist=use_enabled, |
103 |
opconvert=True, token_class=Atom, |
104 |
eapi=pkg.eapi) |
105 |
except portage.exception.InvalidDependString as e: |
106 |
@@ -4961,6 +4974,12 @@ class depgraph(object): |
107 |
self._dynamic_config._visible_pkgs[pkg.root].cpv_inject(pkg) |
108 |
return ret |
109 |
|
110 |
+ def _is_argument(self, pkg): |
111 |
+ for arg, atom in self._iter_atoms_for_pkg(pkg): |
112 |
+ if isinstance(arg, (AtomArg, PackageArg)): |
113 |
+ return True |
114 |
+ return False |
115 |
+ |
116 |
def _want_installed_pkg(self, pkg): |
117 |
""" |
118 |
Given an installed package returned from select_pkg, return |
119 |
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py |
120 |
index cf7966c..3f34102 100644 |
121 |
--- a/pym/_emerge/main.py |
122 |
+++ b/pym/_emerge/main.py |
123 |
@@ -160,6 +160,7 @@ def insert_optional_args(args): |
124 |
'--usepkgonly' : y_or_n, |
125 |
'--verbose' : y_or_n, |
126 |
'--verbose-slot-rebuilds': y_or_n, |
127 |
+ '--with-test-deps' : y_or_n, |
128 |
} |
129 |
|
130 |
short_arg_opts = { |
131 |
@@ -661,6 +662,11 @@ def parse_opts(tmpcmdline, silent=False): |
132 |
"help" : "verbose slot rebuild output", |
133 |
"choices" : true_y_or_n |
134 |
}, |
135 |
+ "--with-test-deps": { |
136 |
+ "help" : "pull in test deps for packages " + \ |
137 |
+ "matched by arguments", |
138 |
+ "choices" : true_y_or_n |
139 |
+ }, |
140 |
} |
141 |
|
142 |
parser = ArgumentParser(add_help=False) |
143 |
@@ -956,6 +962,11 @@ def parse_opts(tmpcmdline, silent=False): |
144 |
else: |
145 |
myoptions.verbose = None |
146 |
|
147 |
+ if myoptions.with_test_deps in true_y: |
148 |
+ myoptions.with_test_deps = True |
149 |
+ else: |
150 |
+ myoptions.with_test_deps = None |
151 |
+ |
152 |
for myopt in options: |
153 |
v = getattr(myoptions, myopt.lstrip("--").replace("-", "_")) |
154 |
if v: |
155 |
diff --git a/pym/portage/tests/resolver/test_with_test_deps.py b/pym/portage/tests/resolver/test_with_test_deps.py |
156 |
new file mode 100644 |
157 |
index 0000000..5bfc6a8 |
158 |
--- /dev/null |
159 |
+++ b/pym/portage/tests/resolver/test_with_test_deps.py |
160 |
@@ -0,0 +1,44 @@ |
161 |
+# Copyright 2014 Gentoo Foundation |
162 |
+# Distributed under the terms of the GNU General Public License v2 |
163 |
+ |
164 |
+from portage.tests import TestCase |
165 |
+from portage.tests.resolver.ResolverPlayground import \ |
166 |
+ ResolverPlayground, ResolverPlaygroundTestCase |
167 |
+ |
168 |
+class WithTestDepsTestCase(TestCase): |
169 |
+ |
170 |
+ def testWithTestDeps(self): |
171 |
+ ebuilds = { |
172 |
+ "app-misc/A-0": { |
173 |
+ "EAPI": "5", |
174 |
+ "IUSE": "test", |
175 |
+ "DEPEND": "test? ( app-misc/B )" |
176 |
+ }, |
177 |
+ "app-misc/B-0": { |
178 |
+ "EAPI": "5", |
179 |
+ "IUSE": "test", |
180 |
+ "DEPEND": "test? ( app-misc/C )" |
181 |
+ }, |
182 |
+ "app-misc/C-0": { |
183 |
+ "EAPI": "5", |
184 |
+ } |
185 |
+ } |
186 |
+ |
187 |
+ test_cases = ( |
188 |
+ # Test that --with-test-deps only pulls in direct |
189 |
+ # test deps of packages matched by arguments. |
190 |
+ ResolverPlaygroundTestCase( |
191 |
+ ["app-misc/A"], |
192 |
+ success = True, |
193 |
+ options = { "--onlydeps": True, "--with-test-deps": True }, |
194 |
+ mergelist = ["app-misc/B-0"]), |
195 |
+ ) |
196 |
+ |
197 |
+ playground = ResolverPlayground(ebuilds=ebuilds, debug=False) |
198 |
+ try: |
199 |
+ for test_case in test_cases: |
200 |
+ playground.run_TestCase(test_case) |
201 |
+ self.assertEqual(test_case.test_success, |
202 |
+ True, test_case.fail_msg) |
203 |
+ finally: |
204 |
+ playground.cleanup() |
205 |
-- |
206 |
2.0.4 |