summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-05-21 03:30:05 -0700
committerZac Medico <zmedico@gentoo.org>2011-05-21 03:30:05 -0700
commitffd08be66d09bf98b25957ac8b99d414f4549d17 (patch)
tree6f1c18c16625eb81fd97931ff54255bb2bc4d228
parentfc3997483120e4003991dabd5d1e58b339579adb (diff)
downloadportage-ffd08be66d09bf98b25957ac8b99d414f4549d17.tar.gz
portage-ffd08be66d09bf98b25957ac8b99d414f4549d17.tar.bz2
portage-ffd08be66d09bf98b25957ac8b99d414f4549d17.zip
test_merge_order: test satisfied circular DEPEND
-rw-r--r--pym/portage/tests/resolver/ResolverPlayground.py13
-rw-r--r--pym/portage/tests/resolver/test_merge_order.py43
2 files changed, 55 insertions, 1 deletions
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
index 2fc37dc47..dd3a944e4 100644
--- a/pym/portage/tests/resolver/ResolverPlayground.py
+++ b/pym/portage/tests/resolver/ResolverPlayground.py
@@ -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)
diff --git a/pym/portage/tests/resolver/test_merge_order.py b/pym/portage/tests/resolver/test_merge_order.py
index be41f8280..62d16d98b 100644
--- a/pym/portage/tests/resolver/test_merge_order.py
+++ b/pym/portage/tests/resolver/test_merge_order.py
@@ -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(