test_merge_order: test satisfied circular DEPEND
authorZac Medico <zmedico@gentoo.org>
Sat, 21 May 2011 10:30:05 +0000 (03:30 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 21 May 2011 10:30:05 +0000 (03:30 -0700)
pym/portage/tests/resolver/ResolverPlayground.py
pym/portage/tests/resolver/test_merge_order.py

index 2fc37dc47fae730330fcbf74967fdbc0d9ca01d2..dd3a944e42a3cdd29c56465321fb6a114dd4f8c1 100644 (file)
@@ -476,6 +476,7 @@ class ResolverPlaygroundTestCase(object):
                self.ignore_mergelist_order = kwargs.pop("ignore_mergelist_order", False)
                self.ambigous_merge_order = kwargs.pop("ambigous_merge_order", False)
                self.check_repo_names = kwargs.pop("check_repo_names", False)
+               self.merge_order_assertions = kwargs.pop("merge_order_assertions", False)
 
                if self.all_permutations:
                        self.requests = list(permutations(request))
@@ -538,6 +539,7 @@ class ResolverPlaygroundTestCase(object):
                                        expected_stack = list(reversed(expected))
                                        got_stack = list(reversed(got))
                                        new_expected = []
+                                       match = True
                                        while got_stack and expected_stack:
                                                got_token = got_stack.pop()
                                                expected_obj = expected_stack.pop()
@@ -554,7 +556,6 @@ class ResolverPlaygroundTestCase(object):
                                                        # result doesn't match, so stop early
                                                        break
                                                new_expected.append(got_token)
-                                               match = True
                                                while got_stack and expected_obj:
                                                        got_token = got_stack.pop()
                                                        try:
@@ -568,14 +569,24 @@ class ResolverPlaygroundTestCase(object):
                                                        break
                                                if expected_obj:
                                                        # result does not match, so stop early
+                                                       match = False
                                                        new_expected.append(tuple(expected_obj))
                                                        break
                                        if expected_stack:
                                                # result does not match, add leftovers to new_expected
+                                               match = False
                                                expected_stack.reverse()
                                                new_expected.extend(expected_stack)
                                        expected = new_expected
 
+                                       if match and self.merge_order_assertions:
+                                               for node1, node2 in self.merge_order_assertions:
+                                                       if not (got.index(node1) < got.index(node2)):
+                                                               fail_msgs.append("atoms: (" + \
+                                                                       ", ".join(result.atoms) + "), key: " + \
+                                                                       ("merge_order_assertions, expected: %s" % \
+                                                                       (node1, node2)) + ", got: " + str(got))
+
                        elif key in ("unstable_keywords", "needed_p_mask_changes") and expected is not None:
                                expected = set(expected)
 
index be41f8280c2524e13fdd606cc8291dea94be6c3c..62d16d98bfb57eec57e618143502440b23570d4e 100644 (file)
@@ -56,6 +56,26 @@ class MergeOrderTestCase(TestCase):
                        "app-misc/circ-runtime-c-1": {
                                "RDEPEND": "app-misc/circ-runtime-a",
                        },
+                       "app-misc/circ-satisfied-a-0": {
+                               "RDEPEND": "app-misc/circ-satisfied-b",
+                       },
+                       "app-misc/circ-satisfied-a-1": {
+                               "RDEPEND": "app-misc/circ-satisfied-b",
+                       },
+                       "app-misc/circ-satisfied-b-0": {
+                               "RDEPEND": "app-misc/circ-satisfied-c",
+                       },
+                       "app-misc/circ-satisfied-b-1": {
+                               "RDEPEND": "app-misc/circ-satisfied-c",
+                       },
+                       "app-misc/circ-satisfied-c-0": {
+                               "DEPEND": "app-misc/circ-satisfied-a",
+                               "RDEPEND": "app-misc/circ-satisfied-a",
+                       },
+                       "app-misc/circ-satisfied-c-1": {
+                               "DEPEND": "app-misc/circ-satisfied-a",
+                               "RDEPEND": "app-misc/circ-satisfied-a",
+                       },
                        "app-misc/installed-blocker-a-1" : {
                                "EAPI"   : "2",
                                "DEPEND" : "!app-misc/blocker-buildtime-a",
@@ -74,6 +94,16 @@ class MergeOrderTestCase(TestCase):
 
                installed = {
                        "app-misc/circ-buildtime-a-0": {},
+                       "app-misc/circ-satisfied-a-0": {
+                               "RDEPEND": "app-misc/circ-satisfied-b",
+                       },
+                       "app-misc/circ-satisfied-b-0": {
+                               "RDEPEND": "app-misc/circ-satisfied-c",
+                       },
+                       "app-misc/circ-satisfied-c-0": {
+                               "DEPEND": "app-misc/circ-satisfied-a",
+                               "RDEPEND": "app-misc/circ-satisfied-a",
+                       },
                        "app-misc/installed-blocker-a-1" : {
                                "EAPI"   : "2",
                                "DEPEND" : "!app-misc/blocker-buildtime-a",
@@ -114,6 +144,19 @@ class MergeOrderTestCase(TestCase):
                                success = True,
                                ambigous_merge_order = True,
                                mergelist = ["app-misc/circ-post-runtime-a-1", ("app-misc/circ-post-runtime-b-1", "app-misc/circ-post-runtime-c-1"), "app-misc/some-app-b-1"]),
+                       # Test optimal merge order for a circular dep that is
+                       # RDEPEND in one direction and DEPEND in the other,
+                       # with all dependencies initially satisfied. Optimally,
+                       # the DEPEND/buildtime dep should be updated before the
+                       # package that depends on it, even though it's feasible
+                       # to update it later since it is already satisfied.
+                       ResolverPlaygroundTestCase(
+                               ["app-misc/circ-satisfied-a", "app-misc/circ-satisfied-b", "app-misc/circ-satisfied-c"],
+                               success = True,
+                               all_permutations = True,
+                               ambigous_merge_order = True,
+                               merge_order_assertions = (("app-misc/circ-satisfied-a-1", "app-misc/circ-satisfied-c-1"),),
+                               mergelist = [("app-misc/circ-satisfied-a-1", "app-misc/circ-satisfied-b-1", "app-misc/circ-satisfied-c-1")]),
                        # installed package has buildtime-only blocker
                        # that should be ignored
                        ResolverPlaygroundTestCase(