Mask USE=test if RESTRICT=test, for bug #273272.
authorZac Medico <zmedico@gentoo.org>
Sat, 2 Feb 2013 09:03:09 +0000 (01:03 -0800)
committerZac Medico <zmedico@gentoo.org>
Sat, 2 Feb 2013 09:03:09 +0000 (01:03 -0800)
This just handles the simple case where RESTRICT=test is not
conditional on any USE flags.

pym/portage/package/ebuild/config.py

index 352b2982aed49061014bc44bee159c4fe7daab80..a40cdd7c20cebd5edf13dbd175289d1f04ea94b1 100644 (file)
@@ -1514,7 +1514,33 @@ class config(object):
                self.configdict["env"].addLazySingleton(
                        "PORTAGE_IUSE", _lazy_iuse_regex, portage_iuse)
 
-               ebuild_force_test = self.get("EBUILD_FORCE_TEST") == "1"
+               if pkg is None:
+                       raw_restrict = pkg_configdict.get("RESTRICT")
+               else:
+                       raw_restrict = pkg._raw_metadata["RESTRICT"]
+
+               restrict_test = False
+               if raw_restrict:
+                       try:
+                               if built_use is not None:
+                                       restrict = use_reduce(raw_restrict,
+                                               uselist=built_use, flat=True)
+                               else:
+                                       # Use matchnone=True to ignore USE conditional parts
+                                       # of RESTRICT, since we want to know whether to mask
+                                       # the "test" flag _before_ we know the USE values
+                                       # that would be needed to evaluate the USE
+                                       # conditionals (see bug #273272).
+                                       restrict = use_reduce(raw_restrict,
+                                               matchnone=True, flat=True)
+                       except PortageException:
+                               pass
+                       else:
+                               restrict_test = "test" in restrict
+
+               ebuild_force_test = not restrict_test and \
+                       self.get("EBUILD_FORCE_TEST") == "1"
+
                if ebuild_force_test and \
                        not hasattr(self, "_ebuild_force_test_msg_shown"):
                                self._ebuild_force_test_msg_shown = True
@@ -1523,7 +1549,8 @@ class config(object):
                if "test" in explicit_iuse or iuse_implicit_match("test"):
                        if "test" not in self.features:
                                use.discard("test")
-                       elif "test" in self.usemask and not ebuild_force_test:
+                       elif restrict_test or \
+                               ("test" in self.usemask and not ebuild_force_test):
                                # "test" is in IUSE and USE=test is masked, so execution
                                # of src_test() probably is not reliable. Therefore,
                                # temporarily disable FEATURES=test just for this package.