Fixes for logic related to FEATURES=test to USE=test mapping:
authorZac Medico <zmedico@gentoo.org>
Fri, 28 Dec 2007 14:40:13 +0000 (14:40 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 28 Dec 2007 14:40:13 +0000 (14:40 -0000)
* Add EBUILD_FORCE_TEST to the environment whitelist and filter
  it from the saved environment in save_ebuild_env().
* Tweak logic inside the ebuild command and config.regenerate()
  so that EBUILD_FORCE_TEST works even in odd cases like when
  USE=test is masked.
* Only make FEATURES=test map to USE=test when "test" is
  actually in IUSE.
* Remove USE=test from the set of implicit IUSE so that useq()
  calls in ebuild.sh properly generate a QA Notice when "test"
  is missing from IUSE.

svn path=/main/trunk/; revision=9064

bin/ebuild
bin/ebuild.sh
bin/isolated-functions.sh
pym/portage/__init__.py

index d5e09dd976ac4b0531bdddac436564c087329c01..7aebd8a3647587986856e535389f6e7d46bad254 100755 (executable)
@@ -130,13 +130,17 @@ def discard_digests(myebuild, mysettings, mydbapi):
                portage._doebuild_manifest_exempt_depend -= 1
 
 tmpsettings = portage.config(clone=portage.settings)
-if "test" in pargs and "test" not in tmpsettings.features:
-       print "Forcing test."
+if "test" in pargs:
+       # This variable is a signal to config.regenerate() to
+       # indicate that the test phase should be enabled regardless
+       # of problems such as masked "test" USE flag.
        tmpsettings["EBUILD_FORCE_TEST"] = "1"
        tmpsettings.backup_changes("EBUILD_FORCE_TEST")
-       tmpsettings.features.append("test")
-       tmpsettings["FEATURES"] = " ".join(tmpsettings.features)
-       tmpsettings.backup_changes("FEATURES")
+       if "test" not in tmpsettings.features:
+               tmpsettings.features.append("test")
+               tmpsettings.features.sort()
+               tmpsettings["FEATURES"] = " ".join(tmpsettings.features)
+               tmpsettings.backup_changes("FEATURES")
 
 build_dir_phases = set(["setup", "unpack", "compile",
        "test", "install", "package", "rpm"])
index 62a271752cd188a4b8afa02ec6b9d969702d8c64..d65ff69e9596f5f25794f4e6897d5d2526fe89f1 100755 (executable)
@@ -919,9 +919,6 @@ dyn_test() {
        fi
        if ! hasq test $FEATURES && [ "${EBUILD_FORCE_TEST}" != "1" ]; then
                vecho ">>> Test phase [not enabled]: ${CATEGORY}/${PF}"
-       elif ! hasq test ${USE} && [ "${EBUILD_FORCE_TEST}" != "1" ]; then
-               ewarn "Skipping make test/check since USE=test is masked."
-               vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
        elif hasq test $RESTRICT; then
                ewarn "Skipping make test/check due to ebuild restriction."
                vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
index a7e8433ada68bec717481230978b4983d6f5b87a..e06fbb826e8cf47f835c59fdfe1b0dab7cb851e8 100755 (executable)
@@ -434,7 +434,7 @@ save_ebuild_env() {
                # portage config variables and variables set directly by portage
                unset BAD BRACKET BUILD_PREFIX COLS \
                        DISTCC_DIR DISTDIR DOC_SYMLINKS_DIR \
-                       EBUILD_EXIT_STATUS_FILE EBUILD_MASTER_PID \
+                       EBUILD_EXIT_STATUS_FILE EBUILD_FORCE_TEST EBUILD_MASTER_PID \
                        ECLASSDIR ECLASS_DEPTH ENDCOL FAKEROOTKEY \
                        GOOD HILITE HOME IMAGE \
                        LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \
index 54c22326fd79e7c29c6ccd8456416cc5f89b9d84..2c826a58a5a76e883c57f93b384227eb62eae333 100644 (file)
@@ -870,8 +870,9 @@ class config(object):
        # in it's bashrc (causing major leakage).
        _environ_whitelist += [
                "BASH_ENV", "BUILD_PREFIX", "D",
-               "DISTDIR", "DOC_SYMLINKS_DIR", "EBUILD_EXIT_STATUS_FILE",
-               "EBUILD", "EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "EMERGE_FROM",
+               "DISTDIR", "DOC_SYMLINKS_DIR", "EBUILD",
+               "EBUILD_EXIT_STATUS_FILE", "EBUILD_FORCE_TEST",
+               "EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "EMERGE_FROM",
                "FEATURES", "FILESDIR", "HOME", "PATH",
                "PKGUSE", "PKG_LOGDIR", "PKG_TMPDIR",
                "PORTAGE_ACTUAL_DISTDIR", "PORTAGE_ARCHLIST",
@@ -1535,8 +1536,8 @@ class config(object):
                                        self[var] = "0"
                                self.backup_changes(var)
 
+                       # initialize self.features
                        self.regenerate()
-                       self.features = portage.util.unique_array(self["FEATURES"].split())
 
                        if local_config:
                                self._accept_license = \
@@ -2316,19 +2317,34 @@ class config(object):
 
                myflags.update(self.useforce)
 
+               iuse = self.configdict["pkg"].get("IUSE","").split()
+               iuse = [ x.lstrip("+-") for x in iuse ]
                # FEATURES=test should imply USE=test
-               if "test" in self.configlist[-1].get("FEATURES","").split():
-                       myflags.add("test")
-                       if self.get("EBUILD_FORCE_TEST") == "1":
-                               self.usemask.discard("test")
+               if not hasattr(self, "features"):
+                       self.features = list(sorted(set(
+                               self.configlist[-1].get("FEATURES","").split())))
+               self["FEATURES"] = " ".join(self.features)
+               if "test" in self.features and "test" in iuse:
+                       ebuild_force_test = self.get("EBUILD_FORCE_TEST") == "1"
+                       if ebuild_force_test and self.get("EBUILD_PHASE") == "test":
+                               writemsg("Forcing test.\n", noiselevel=-1)
+                       if "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.
+                               self["FEATURES"] = " ".join(x for x in self.features \
+                                       if x != "test")
+                               myflags.discard("test")
+                       else:
+                               myflags.add("test")
+                               if ebuild_force_test:
+                                       self.usemask.discard("test")
 
                usesplit = [ x for x in myflags if \
                        x not in self.usemask]
 
                # Use the calculated USE flags to regenerate the USE_EXPAND flags so
                # that they are consistent.
-               iuse = self.configdict["pkg"].get("IUSE","").split()
-               iuse = [ x.lstrip("+-") for x in iuse ]
                for var in use_expand:
                        prefix = var.lower() + "_"
                        prefix_len = len(prefix)
@@ -2396,7 +2412,6 @@ class config(object):
                #  * Masked flags, such as those from {,package}use.mask
                #  * Forced flags, such as those from {,package}use.force
                #  * build and bootstrap flags used by bootstrap.sh
-               #  * The "test" flag that's enabled by FEATURES=test
 
                # Do this even when there's no package since setcpv() can
                # optimize away regenerate() calls.
@@ -2425,7 +2440,6 @@ class config(object):
                # build and bootstrap flags used by bootstrap.sh
                iuse_implicit.add("build")
                iuse_implicit.add("bootstrap")
-               iuse_implicit.add("test")
 
                iuse_grep = iuse_implicit.copy()
                if use_expand_hidden_raw: