From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 336B5138825 for ; Sun, 9 Nov 2014 04:50:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4266FE08F0; Sun, 9 Nov 2014 04:50:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A7D17E08EE for ; Sun, 9 Nov 2014 04:50:10 +0000 (UTC) Received: from localhost.localdomain (ip70-181-96-121.oc.oc.cox.net [70.181.96.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 655763401D6; Sun, 9 Nov 2014 04:50:08 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Cc: Zac Medico Subject: [gentoo-portage-dev] [PATCH] Add emerge --with-test-deps option for bug #520652 Date: Sat, 8 Nov 2014 20:50:02 -0800 Message-Id: <1415508602-15169-1-git-send-email-zmedico@gentoo.org> X-Mailer: git-send-email 2.0.4 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 66003154-8b65-4226-b0c1-b8949eea6e40 X-Archives-Hash: 786433253aca30e2d6cbd7b6ae7dc6db 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