Skip to content

Commit

Permalink
Bind FEATURES=-test to USE=-test for bug #373209.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zmedico committed Sep 13, 2012
1 parent 34fd670 commit 6b19f71
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 8 deletions.
9 changes: 9 additions & 0 deletions man/emerge.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions man/make.conf.5
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions pym/_emerge/depgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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
Expand Down Expand Up @@ -1234,12 +1235,14 @@ def _reinstall_for_flags(self, pkg, forced_flags,
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
Expand Down
8 changes: 5 additions & 3 deletions pym/_emerge/resolver/output_helpers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,6 +17,7 @@
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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions pym/portage/package/ebuild/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
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)
Expand Down Expand Up @@ -1479,6 +1481,11 @@ def setcpv(self, mycpv, use_cache=None, mydb=None):
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 \
Expand Down
2 changes: 1 addition & 1 deletion pym/portage/tests/resolver/ResolverPlayground.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",))
Expand Down
68 changes: 68 additions & 0 deletions pym/portage/tests/resolver/test_features_test_use.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 6b19f71

Please sign in to comment.