* [gentoo-portage-dev] [PATCH] Add emerge --with-test-deps option for bug #520652
@ 2014-11-09 4:50 Zac Medico
2014-11-20 10:05 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
0 siblings, 1 reply; 3+ messages in thread
From: Zac Medico @ 2014-11-09 4:50 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
For packages matched by arguments, this option will pull in dependencies
that are conditional on the "test" USE flag, even if FEATURES=test is not
enabled for the matched packages. The state of the "test" USE flag is not
affected by this option. It only changes the effective dependencies
which are processed by the depgraph._add_pkg_deps method.
X-Gentoo-Bug: 520652
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=520652
---
man/emerge.1 | 8 ++++-
pym/_emerge/create_depgraph_params.py | 5 +++
pym/_emerge/depgraph.py | 23 ++++++++++--
pym/_emerge/main.py | 11 ++++++
pym/portage/tests/resolver/test_with_test_deps.py | 44 +++++++++++++++++++++++
5 files changed, 88 insertions(+), 3 deletions(-)
create mode 100644 pym/portage/tests/resolver/test_with_test_deps.py
diff --git a/man/emerge.1 b/man/emerge.1
index bbe71ac..a206e8e 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Oct 2014" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Nov 2014" "Portage VERSION" "Portage"
.SH "NAME"
emerge \- Command\-line interface to the Portage system
.SH "SYNOPSIS"
@@ -894,6 +894,12 @@ installation actions, meaning they will not be installed, and
This setting can be added to
\fBEMERGE_DEFAULT_OPTS\fR (see make.conf(5)) and later overridden via the
command line.
+.TP
+.BR "\-\-with\-test\-deps [ y | n ]"
+For packages matched by arguments, this option will pull in dependencies
+that are conditional on the "test" USE flag, even if "test" is not
+enabled in \fBFEATURES\fR for the matched packages. (see \fBmake.conf\fR(5)
+for more information about \fBFEATURES\fR settings).
.SH "ENVIRONMENT OPTIONS"
.TP
\fBEPREFIX\fR = \fI[path]\fR
diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py
index 225b792..6f74de7 100644
--- a/pym/_emerge/create_depgraph_params.py
+++ b/pym/_emerge/create_depgraph_params.py
@@ -21,6 +21,7 @@ def create_depgraph_params(myopts, myaction):
# removal by the --depclean action as soon as possible
# ignore_built_slot_operator_deps: ignore the slot/sub-slot := operator parts
# of dependencies that have been recorded when packages where built
+ # with_test_deps: pull in test deps for packages matched by arguments
myparams = {"recurse" : True}
bdeps = myopts.get("--with-bdeps")
@@ -104,6 +105,10 @@ def create_depgraph_params(myopts, myaction):
# other option like --update.
myparams.pop("selective", None)
+ with_test_deps = myopts.get("--with-test-deps")
+ if with_test_deps is not None:
+ myparams["with_test_deps"] = with_test_deps
+
if '--debug' in myopts:
writemsg_level('\n\nmyparams %s\n\n' % myparams,
noiselevel=-1, level=logging.DEBUG)
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 94eaed8..ddadb22 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -2691,6 +2691,19 @@ class depgraph(object):
for k in Package._dep_keys:
edepend[k] = metadata[k]
+ with_test_deps = not removal_action and \
+ "with_test_deps" in \
+ self._dynamic_config.myparams and \
+ pkg.depth == 0 and \
+ "test" not in pkg.use.enabled and \
+ pkg.iuse.is_valid_flag("test") and \
+ self._is_argument(pkg)
+
+ use_enabled = self._pkg_use_enabled(pkg)
+ if with_test_deps:
+ use_enabled = set(use_enabled)
+ use_enabled.add("test")
+
if not pkg.built and \
"--buildpkgonly" in self._frozen_config.myopts and \
"deep" not in self._dynamic_config.myparams:
@@ -2774,7 +2787,7 @@ class depgraph(object):
try:
dep_string = portage.dep.use_reduce(dep_string,
- uselist=self._pkg_use_enabled(pkg),
+ uselist=use_enabled,
is_valid_flag=pkg.iuse.is_valid_flag,
opconvert=True, token_class=Atom,
eapi=pkg.eapi)
@@ -2789,7 +2802,7 @@ class depgraph(object):
# practical to ignore this issue for installed packages.
try:
dep_string = portage.dep.use_reduce(dep_string,
- uselist=self._pkg_use_enabled(pkg),
+ uselist=use_enabled,
opconvert=True, token_class=Atom,
eapi=pkg.eapi)
except portage.exception.InvalidDependString as e:
@@ -4961,6 +4974,12 @@ class depgraph(object):
self._dynamic_config._visible_pkgs[pkg.root].cpv_inject(pkg)
return ret
+ def _is_argument(self, pkg):
+ for arg, atom in self._iter_atoms_for_pkg(pkg):
+ if isinstance(arg, (AtomArg, PackageArg)):
+ return True
+ return False
+
def _want_installed_pkg(self, pkg):
"""
Given an installed package returned from select_pkg, return
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index cf7966c..3f34102 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -160,6 +160,7 @@ def insert_optional_args(args):
'--usepkgonly' : y_or_n,
'--verbose' : y_or_n,
'--verbose-slot-rebuilds': y_or_n,
+ '--with-test-deps' : y_or_n,
}
short_arg_opts = {
@@ -661,6 +662,11 @@ def parse_opts(tmpcmdline, silent=False):
"help" : "verbose slot rebuild output",
"choices" : true_y_or_n
},
+ "--with-test-deps": {
+ "help" : "pull in test deps for packages " + \
+ "matched by arguments",
+ "choices" : true_y_or_n
+ },
}
parser = ArgumentParser(add_help=False)
@@ -956,6 +962,11 @@ def parse_opts(tmpcmdline, silent=False):
else:
myoptions.verbose = None
+ if myoptions.with_test_deps in true_y:
+ myoptions.with_test_deps = True
+ else:
+ myoptions.with_test_deps = None
+
for myopt in options:
v = getattr(myoptions, myopt.lstrip("--").replace("-", "_"))
if v:
diff --git a/pym/portage/tests/resolver/test_with_test_deps.py b/pym/portage/tests/resolver/test_with_test_deps.py
new file mode 100644
index 0000000..5bfc6a8
--- /dev/null
+++ b/pym/portage/tests/resolver/test_with_test_deps.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import \
+ ResolverPlayground, ResolverPlaygroundTestCase
+
+class WithTestDepsTestCase(TestCase):
+
+ def testWithTestDeps(self):
+ ebuilds = {
+ "app-misc/A-0": {
+ "EAPI": "5",
+ "IUSE": "test",
+ "DEPEND": "test? ( app-misc/B )"
+ },
+ "app-misc/B-0": {
+ "EAPI": "5",
+ "IUSE": "test",
+ "DEPEND": "test? ( app-misc/C )"
+ },
+ "app-misc/C-0": {
+ "EAPI": "5",
+ }
+ }
+
+ test_cases = (
+ # Test that --with-test-deps only pulls in direct
+ # test deps of packages matched by arguments.
+ ResolverPlaygroundTestCase(
+ ["app-misc/A"],
+ success = True,
+ options = { "--onlydeps": True, "--with-test-deps": True },
+ mergelist = ["app-misc/B-0"]),
+ )
+
+ playground = ResolverPlayground(ebuilds=ebuilds, debug=False)
+ try:
+ for test_case in test_cases:
+ playground.run_TestCase(test_case)
+ self.assertEqual(test_case.test_success,
+ True, test_case.fail_msg)
+ finally:
+ playground.cleanup()
--
2.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-portage-dev] [PATCH v2] Add emerge --with-test-deps option for bug #520652
2014-11-09 4:50 [gentoo-portage-dev] [PATCH] Add emerge --with-test-deps option for bug #520652 Zac Medico
@ 2014-11-20 10:05 ` Zac Medico
2014-11-24 6:55 ` Alexander Berntsen
0 siblings, 1 reply; 3+ messages in thread
From: Zac Medico @ 2014-11-20 10:05 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
For packages matched by arguments, this option will pull in dependencies
that are conditional on the "test" USE flag, even if FEATURES=test is not
enabled for the matched packages. The state of the "test" USE flag is not
affected by this option. It only changes the effective dependencies
which are processed by the depgraph._add_pkg_deps method.
X-Gentoo-Bug: 520652
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=520652
---
PATCH v2 fixes the code in _add_pkg_deps to use _pkg_use_enabled instead
of accessing pkg.use.unabled directly (we should not bypass
_pkg_use_enabled unless there is a very good reason for it).
man/emerge.1 | 8 ++++-
pym/_emerge/create_depgraph_params.py | 5 +++
pym/_emerge/depgraph.py | 24 +++++++++++--
pym/_emerge/main.py | 11 ++++++
pym/portage/tests/resolver/test_with_test_deps.py | 44 +++++++++++++++++++++++
5 files changed, 89 insertions(+), 3 deletions(-)
create mode 100644 pym/portage/tests/resolver/test_with_test_deps.py
diff --git a/man/emerge.1 b/man/emerge.1
index bbe71ac..a206e8e 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Oct 2014" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Nov 2014" "Portage VERSION" "Portage"
.SH "NAME"
emerge \- Command\-line interface to the Portage system
.SH "SYNOPSIS"
@@ -894,6 +894,12 @@ installation actions, meaning they will not be installed, and
This setting can be added to
\fBEMERGE_DEFAULT_OPTS\fR (see make.conf(5)) and later overridden via the
command line.
+.TP
+.BR "\-\-with\-test\-deps [ y | n ]"
+For packages matched by arguments, this option will pull in dependencies
+that are conditional on the "test" USE flag, even if "test" is not
+enabled in \fBFEATURES\fR for the matched packages. (see \fBmake.conf\fR(5)
+for more information about \fBFEATURES\fR settings).
.SH "ENVIRONMENT OPTIONS"
.TP
\fBEPREFIX\fR = \fI[path]\fR
diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py
index 225b792..6f74de7 100644
--- a/pym/_emerge/create_depgraph_params.py
+++ b/pym/_emerge/create_depgraph_params.py
@@ -21,6 +21,7 @@ def create_depgraph_params(myopts, myaction):
# removal by the --depclean action as soon as possible
# ignore_built_slot_operator_deps: ignore the slot/sub-slot := operator parts
# of dependencies that have been recorded when packages where built
+ # with_test_deps: pull in test deps for packages matched by arguments
myparams = {"recurse" : True}
bdeps = myopts.get("--with-bdeps")
@@ -104,6 +105,10 @@ def create_depgraph_params(myopts, myaction):
# other option like --update.
myparams.pop("selective", None)
+ with_test_deps = myopts.get("--with-test-deps")
+ if with_test_deps is not None:
+ myparams["with_test_deps"] = with_test_deps
+
if '--debug' in myopts:
writemsg_level('\n\nmyparams %s\n\n' % myparams,
noiselevel=-1, level=logging.DEBUG)
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 6f1910d..505d8a8 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -2699,6 +2699,20 @@ class depgraph(object):
for k in Package._dep_keys:
edepend[k] = metadata[k]
+ use_enabled = self._pkg_use_enabled(pkg)
+
+ with_test_deps = not removal_action and \
+ "with_test_deps" in \
+ self._dynamic_config.myparams and \
+ pkg.depth == 0 and \
+ "test" not in use_enabled and \
+ pkg.iuse.is_valid_flag("test") and \
+ self._is_argument(pkg)
+
+ if with_test_deps:
+ use_enabled = set(use_enabled)
+ use_enabled.add("test")
+
if not pkg.built and \
"--buildpkgonly" in self._frozen_config.myopts and \
"deep" not in self._dynamic_config.myparams:
@@ -2782,7 +2796,7 @@ class depgraph(object):
try:
dep_string = portage.dep.use_reduce(dep_string,
- uselist=self._pkg_use_enabled(pkg),
+ uselist=use_enabled,
is_valid_flag=pkg.iuse.is_valid_flag,
opconvert=True, token_class=Atom,
eapi=pkg.eapi)
@@ -2797,7 +2811,7 @@ class depgraph(object):
# practical to ignore this issue for installed packages.
try:
dep_string = portage.dep.use_reduce(dep_string,
- uselist=self._pkg_use_enabled(pkg),
+ uselist=use_enabled,
opconvert=True, token_class=Atom,
eapi=pkg.eapi)
except portage.exception.InvalidDependString as e:
@@ -4969,6 +4983,12 @@ class depgraph(object):
self._dynamic_config._visible_pkgs[pkg.root].cpv_inject(pkg)
return ret
+ def _is_argument(self, pkg):
+ for arg, atom in self._iter_atoms_for_pkg(pkg):
+ if isinstance(arg, (AtomArg, PackageArg)):
+ return True
+ return False
+
def _want_installed_pkg(self, pkg):
"""
Given an installed package returned from select_pkg, return
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index cf7966c..3f34102 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -160,6 +160,7 @@ def insert_optional_args(args):
'--usepkgonly' : y_or_n,
'--verbose' : y_or_n,
'--verbose-slot-rebuilds': y_or_n,
+ '--with-test-deps' : y_or_n,
}
short_arg_opts = {
@@ -661,6 +662,11 @@ def parse_opts(tmpcmdline, silent=False):
"help" : "verbose slot rebuild output",
"choices" : true_y_or_n
},
+ "--with-test-deps": {
+ "help" : "pull in test deps for packages " + \
+ "matched by arguments",
+ "choices" : true_y_or_n
+ },
}
parser = ArgumentParser(add_help=False)
@@ -956,6 +962,11 @@ def parse_opts(tmpcmdline, silent=False):
else:
myoptions.verbose = None
+ if myoptions.with_test_deps in true_y:
+ myoptions.with_test_deps = True
+ else:
+ myoptions.with_test_deps = None
+
for myopt in options:
v = getattr(myoptions, myopt.lstrip("--").replace("-", "_"))
if v:
diff --git a/pym/portage/tests/resolver/test_with_test_deps.py b/pym/portage/tests/resolver/test_with_test_deps.py
new file mode 100644
index 0000000..5bfc6a8
--- /dev/null
+++ b/pym/portage/tests/resolver/test_with_test_deps.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import \
+ ResolverPlayground, ResolverPlaygroundTestCase
+
+class WithTestDepsTestCase(TestCase):
+
+ def testWithTestDeps(self):
+ ebuilds = {
+ "app-misc/A-0": {
+ "EAPI": "5",
+ "IUSE": "test",
+ "DEPEND": "test? ( app-misc/B )"
+ },
+ "app-misc/B-0": {
+ "EAPI": "5",
+ "IUSE": "test",
+ "DEPEND": "test? ( app-misc/C )"
+ },
+ "app-misc/C-0": {
+ "EAPI": "5",
+ }
+ }
+
+ test_cases = (
+ # Test that --with-test-deps only pulls in direct
+ # test deps of packages matched by arguments.
+ ResolverPlaygroundTestCase(
+ ["app-misc/A"],
+ success = True,
+ options = { "--onlydeps": True, "--with-test-deps": True },
+ mergelist = ["app-misc/B-0"]),
+ )
+
+ playground = ResolverPlayground(ebuilds=ebuilds, debug=False)
+ try:
+ for test_case in test_cases:
+ playground.run_TestCase(test_case)
+ self.assertEqual(test_case.test_success,
+ True, test_case.fail_msg)
+ finally:
+ playground.cleanup()
--
2.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [gentoo-portage-dev] [PATCH v2] Add emerge --with-test-deps option for bug #520652
2014-11-20 10:05 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
@ 2014-11-24 6:55 ` Alexander Berntsen
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Berntsen @ 2014-11-24 6:55 UTC (permalink / raw
To: gentoo-portage-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I am unable to fully take into account every possible event this
affects in a 10KLOC file full of side-effects file. So I'm going to
just trust you and your unit test, and consequently ACK this. The
patch, isolated, looks fine to me.
- --
Alexander
bernalex@gentoo.org
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iF4EAREIAAYFAlRy1koACgkQRtClrXBQc7XmGgD9GdQ6sytqZ5E3fWDIFqyx0LnE
fdbDHLJ06XuZF5LO77YA+gOz0ooyTomea9hUGCGaXz1CAz8iOlmthiRCPJ9yI4ma
=6dAa
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-24 6:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-09 4:50 [gentoo-portage-dev] [PATCH] Add emerge --with-test-deps option for bug #520652 Zac Medico
2014-11-20 10:05 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
2014-11-24 6:55 ` Alexander Berntsen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox