public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/_emerge/, pym/portage/tests/resolver/, man/
@ 2014-11-24  7:29 Zac Medico
  0 siblings, 0 replies; only message in thread
From: Zac Medico @ 2014-11-24  7:29 UTC (permalink / raw
  To: gentoo-commits

commit:     6205081cd90b94ccb12d17784c12b31229eb6b3c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  9 04:20:42 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Nov 24 07:20:54 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6205081c

Add emerge --with-test-deps option for bug #520652

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
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>

---
 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(-)

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()


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-11-24  7:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-24  7:29 [gentoo-commits] proj/portage:master commit in: pym/_emerge/, pym/portage/tests/resolver/, man/ Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox