commit:     71169bb71c3b55ebfb1dba61fd37231535b1699e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 31 06:14:03 2025 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 31 17:07:52 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=71169bb7

--with-test-deps: handle masked test flag

Bug: https://bugs.gentoo.org/968199
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/_emerge/depgraph.py                           |  1 +
 lib/portage/tests/resolver/test_with_test_deps.py | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index d3d97b59bc..5ec5d802f5 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -3992,6 +3992,7 @@ class depgraph:
             and pkg.depth == 0
             and "test" not in use_enabled
             and pkg.iuse.is_valid_flag("test")
+            and "test" not in pkg.use.mask
             and self._is_argument(pkg)
         )
 

diff --git a/lib/portage/tests/resolver/test_with_test_deps.py 
b/lib/portage/tests/resolver/test_with_test_deps.py
index 843447a069..9e82c8decb 100644
--- a/lib/portage/tests/resolver/test_with_test_deps.py
+++ b/lib/portage/tests/resolver/test_with_test_deps.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Gentoo Foundation
+# Copyright 2014-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -10,6 +10,11 @@ from portage.tests.resolver.ResolverPlayground import (
 
 class WithTestDepsTestCase(TestCase):
     def testWithTestDeps(self):
+        profile = {
+            "eapi": "8",
+            "package.use.mask": ("=app-misc/H-0 test",),
+        }
+
         ebuilds = {
             "app-misc/A-0": {
                 "EAPI": "5",
@@ -44,6 +49,12 @@ class WithTestDepsTestCase(TestCase):
                 "IUSE": "+test",
                 "DEPEND": "test? ( app-misc/F )",
             },
+            # The test flag is masked in package.use.mask.
+            "app-misc/H-0": {
+                "EAPI": "8",
+                "IUSE": "+test",
+                "DEPEND": "test? ( app-misc/C )",
+            },
         }
 
         test_cases = (
@@ -74,9 +85,16 @@ class WithTestDepsTestCase(TestCase):
                     "app-misc/F-0": {frozenset({("test", False)})},
                 },
             ),
+            # Test that --with-test-deps respects package.use.mask.
+            ResolverPlaygroundTestCase(
+                ["app-misc/H"],
+                success=True,
+                options={"--with-test-deps": True},
+                mergelist=[("app-misc/H-0")],
+            ),
         )
 
-        playground = ResolverPlayground(ebuilds=ebuilds, debug=False)
+        playground = ResolverPlayground(ebuilds=ebuilds, profile=profile, 
debug=False)
         try:
             for test_case in test_cases:
                 playground.run_TestCase(test_case)

Reply via email to