Bind FEATURES=-test to USE=-test for bug #373209.
authorZac Medico <zmedico@gentoo.org>
Thu, 13 Sep 2012 22:47:13 +0000 (15:47 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 13 Sep 2012 22:47:13 +0000 (15:47 -0700)
Also, make options like emerge --newuse ignore the state of USE=test,
since users typically don't want to trigger a bunch of rebuilds when
they enable or disable FEATURES=test.

man/emerge.1
man/make.conf.5
pym/_emerge/depgraph.py
pym/_emerge/resolver/output_helpers.py
pym/portage/package/ebuild/config.py
pym/portage/tests/resolver/ResolverPlayground.py
pym/portage/tests/resolver/test_features_test_use.py [new file with mode: 0644]

index a25c573bb70113cb6dde19d0d02dbed646fbdd46..65eefa214a60b15e29b0b7c85ff27940a7d29938 100644 (file)
@@ -369,6 +369,10 @@ changed since installation. This option also implies the
 \fB\-\-selective\fR option. Unlike \fB\-\-newuse\fR, the
 \fB\-\-changed\-use\fR option does not trigger reinstallation when
 flags that the user has not enabled are added or removed.
+
+NOTE: This option ignores the state of the "test" USE flag, since that flag
+has a special binding to FEATURES="test" (see \fBmake.conf\fR(5) for more
+information about \fBFEATURES\fR settings).
 .TP
 .BR "\-\-changelog " (\fB\-l\fR)
 Use this in conjunction with the \fB\-\-pretend\fR option.  This will
@@ -538,6 +542,10 @@ settings. If you would like to skip rebuilds for which disabled flags have
 been added to or removed from IUSE, see the related
 \fB\-\-changed\-use\fR option. If you would like to skip rebuilds for
 specific packages, see the \fB\-\-exclude\fR option.
+
+NOTE: This option ignores the state of the "test" USE flag, since that flag
+has a special binding to FEATURES="test" (see \fBmake.conf\fR(5) for more
+information about \fBFEATURES\fR settings).
 .TP
 .BR "\-\-noconfmem"
 Causes portage to disregard merge records indicating that a config file
@@ -781,6 +789,7 @@ Symbol      Location        Meaning
 *      suffix  transition to or from the enabled state
 %      suffix  newly added or removed
 ()     circumfix       forced, masked, or removed
+{}     circumfix       state is bound to FEATURES settings
 .TE
 .TP
 .BR "\-\-verbose\-main\-repo\-display"
index e2a16a51dd657244aaafc8b1916efc463a4a695c..f11bfcbe794fc6d5f524dc5be10923aa4bdc7f58 100644 (file)
@@ -1,4 +1,4 @@
-.TH "MAKE.CONF" "5" "Aug 2012" "Portage VERSION" "Portage"
+.TH "MAKE.CONF" "5" "Sep 2012" "Portage VERSION" "Portage"
 .SH "NAME"
 make.conf \- custom settings for Portage
 .SH "SYNOPSIS"
@@ -514,7 +514,10 @@ bits from any file that is not listed in \fI/etc/portage/suidctl.conf\fR.
 Run package\-specific tests during each merge to help make sure 
 the package compiled properly.  See \fItest\fR in \fBebuild\fR(1) 
 and \fIsrc_test()\fR in \fBebuild\fR(5). This feature implies the "test"
-\fBUSE\fR flag.
+\fBUSE\fR flag if it is a member of \fBIUSE\fR, either explicitly or
+implicitly (see \fBebuild\fR(5) for more information about \fBIUSE\fR).
+The "test" \fBUSE\fR flag is also automatically disabled when the
+"test" feature is disabled.
 .TP
 .B test\-fail\-continue
 If "test" is enabled \fBFEATURES\fR and the test phase of an ebuild fails,
index e388065fc3f6a2dc3f9636078886bff12768417f..ac70d4315ef6a98d449c606d6acd3d8af5830ee4 100644 (file)
@@ -29,6 +29,7 @@ from portage.exception import (InvalidAtom, InvalidDependString,
 from portage.output import colorize, create_color_func, \
        darkgreen, green
 bad = create_color_func("BAD")
+from portage.package.ebuild.config import _feature_flags
 from portage.package.ebuild.getmaskingstatus import \
        _getmaskingstatus, _MaskReason
 from portage._sets import SETPREFIX
@@ -1234,12 +1235,14 @@ class depgraph(object):
                                cur_iuse).difference(forced_flags))
                        flags.update(orig_iuse.intersection(orig_use).symmetric_difference(
                                cur_iuse.intersection(cur_use)))
+                       flags.difference_update(_feature_flags)
                        if flags:
                                return flags
 
                elif changed_use or binpkg_respect_use:
-                       flags = orig_iuse.intersection(orig_use).symmetric_difference(
-                               cur_iuse.intersection(cur_use))
+                       flags = set(orig_iuse.intersection(orig_use).symmetric_difference(
+                               cur_iuse.intersection(cur_use)))
+                       flags.difference_update(_feature_flags)
                        if flags:
                                return flags
                return None
index e751dd8e441930d477018627c70ca970c0a6b19d..dc622bd9d231fe674adbfb33597b192056ad0d35 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 """Contains private support functions for the Display class
@@ -17,6 +17,7 @@ from portage._sets.base import InternalPackageSet
 from portage.output import (blue, bold, colorize, create_color_func,
        green, red, teal, yellow)
 bad = create_color_func("BAD")
+from portage.package.ebuild.config import _feature_flags
 from portage.util import shlex_split, writemsg
 from portage.versions import catpkgsplit
 
@@ -245,7 +246,6 @@ def _format_size(mysize):
                mystr=mystr[:mycount]+","+mystr[mycount:]
        return mystr+" kB"
 
-
 def _create_use_string(conf, name, cur_iuse, iuse_forced, cur_use,
        old_iuse, old_use,
        is_new, reinst_flags):
@@ -299,7 +299,9 @@ def _create_use_string(conf, name, cur_iuse, iuse_forced, cur_use,
                        elif flag in old_use:
                                flag_str = green("-" + flag) + "*"
                if flag_str:
-                       if flag in iuse_forced:
+                       if flag in _feature_flags:
+                               flag_str = "{" + flag_str + "}"
+                       elif flag in iuse_forced:
                                flag_str = "(" + flag_str + ")"
                        if isEnabled:
                                enabled.append(flag_str)
index 6ca1cb5b8a569b2a86b7630da6465b39c51072c9..bb0a7c1c4504be6a9bd440534531addf3ec12576 100644 (file)
@@ -60,6 +60,8 @@ from portage.package.ebuild._config.helper import ordered_by_atom_specificity, p
 if sys.hexversion >= 0x3000000:
        basestring = str
 
+_feature_flags = frozenset(["test"])
+
 def autouse(myvartree, use_cache=1, mysettings=None):
        warnings.warn("portage.autouse() is deprecated",
                DeprecationWarning, stacklevel=2)
@@ -1479,6 +1481,11 @@ class config(object):
                                if ebuild_force_test and "test" in self.usemask:
                                        self.usemask = \
                                                frozenset(x for x in self.usemask if x != "test")
+               elif "test" in explicit_iuse or iuse_implicit_match("test"):
+                       if "test" in self.usemask or "test" not in self.features:
+                               use.discard("test")
+                       elif "test" in self.features:
+                               use.add("test")
 
                # Allow _* flags from USE_EXPAND wildcards to pass through here.
                use.difference_update([x for x in use \
index 324ef9dd782c33a91b4f570688a025f275d3683c..3bda6070d552ab294947aa22882cc2279e387534 100644 (file)
@@ -34,7 +34,7 @@ class ResolverPlayground(object):
        its work.
        """
 
-       config_files = frozenset(("eapi", "package.accept_keywords", "package.use",
+       config_files = frozenset(("eapi", "make.conf", "package.accept_keywords", "package.use",
                "package.use.stable.mask", "package.mask", "package.keywords",
                "package.unmask", "package.properties", "package.license", "use.mask", "use.force",
                "layout.conf",))
diff --git a/pym/portage/tests/resolver/test_features_test_use.py b/pym/portage/tests/resolver/test_features_test_use.py
new file mode 100644 (file)
index 0000000..bdd179d
--- /dev/null
@@ -0,0 +1,68 @@
+# Copyright 2012 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 FeaturesTestUse(TestCase):
+
+       def testFeaturesTestUse(self):
+               ebuilds = {
+                       "dev-libs/A-1" : {
+                               "IUSE": "test"
+                       },
+                       "dev-libs/B-1" : {
+                               "IUSE": "test foo"
+                       },
+               }
+
+               installed = {
+                       "dev-libs/A-1" : {
+                               "USE": "",
+                               "IUSE": "test"
+                       },
+                       "dev-libs/B-1" : {
+                               "USE": "foo",
+                               "IUSE": "test foo"
+                       },
+               }
+
+               user_config = {
+                       "make.conf" : ("FEATURES=test", "USE=\"-test -foo\"")
+               }
+
+               test_cases = (
+
+                       # USE=test state should not trigger --newuse rebuilds, as
+                       # specified in bug #373209, comment #3.
+                       ResolverPlaygroundTestCase(
+                               ["dev-libs/A"],
+                               options = {"--newuse": True, "--selective": True},
+                               success = True,
+                               mergelist = []),
+
+                       # USE=-test -> USE=test, with USE=test forced by FEATURES=test
+                       ResolverPlaygroundTestCase(
+                               ["dev-libs/A"],
+                               options = {},
+                               success = True,
+                               mergelist = ["dev-libs/A-1"]),
+
+                       # USE=foo -> USE=-foo, with USE=test forced by FEATURES=test
+                       ResolverPlaygroundTestCase(
+                               ["dev-libs/B"],
+                               options = {"--newuse": True, "--selective": True},
+                               success = True,
+                               mergelist = ["dev-libs/B-1"]),
+               )
+
+               playground = ResolverPlayground(ebuilds=ebuilds,
+                       installed=installed, user_config=user_config, 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()
+