commit:     15c173dcea2401a13cfb3313918c77d7dbde133d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 11 03:28:27 2024 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Feb 11 03:29:23 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=15c173dc

DuplicateOverlapDNFTestCase: Add test for bug 891137

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

 lib/portage/tests/dep/test_overlap_dnf.py | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/lib/portage/tests/dep/test_overlap_dnf.py 
b/lib/portage/tests/dep/test_overlap_dnf.py
index dfeded3b40..77352021a9 100644
--- a/lib/portage/tests/dep/test_overlap_dnf.py
+++ b/lib/portage/tests/dep/test_overlap_dnf.py
@@ -1,4 +1,4 @@
-# Copyright 2017 Gentoo Foundation
+# Copyright 2017-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -46,3 +46,31 @@ class OverlapDNFTestCase(TestCase):
                 _overlap_dnf(use_reduce(dep_str, token_class=Atom, 
opconvert=True)),
                 result,
             )
+
+
+class DuplicateOverlapDNFTestCase(TestCase):
+    def testDuplicateOverlapDNF(self):
+        """
+        Demonstrate unnecessary DNF expansion for duplicate
+        any-of blocks as in bug 891137.
+        """
+        test_cases = (
+            (
+                "|| ( cat/A cat/B ) || ( cat/A cat/B )",
+                [
+                    [
+                        "||",
+                        ["cat/A", "cat/A"],
+                        ["cat/A", "cat/B"],
+                        ["cat/B", "cat/A"],
+                        ["cat/B", "cat/B"],
+                    ],
+                ],
+            ),
+        )
+
+        for dep_str, result in test_cases:
+            self.assertEqual(
+                _overlap_dnf(use_reduce(dep_str, token_class=Atom, 
opconvert=True)),
+                result,
+            )

Reply via email to