public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/
Date: Sat, 21 May 2011 00:51:38 +0000 (UTC)	[thread overview]
Message-ID: <286326e79fcc3b7246863f12c4d7376c9e06a673.zmedico@gentoo> (raw)

commit:     286326e79fcc3b7246863f12c4d7376c9e06a673
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 21 00:51:09 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 21 00:51:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=286326e7

ResolverPlayground: support ambigous_merge_order

---
 pym/portage/tests/resolver/ResolverPlayground.py |   49 ++++++++++++++++++++-
 pym/portage/tests/resolver/test_merge_order.py   |   45 ++++++++++++++++++++
 2 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
index 2020cf3..5d1c1b3 100644
--- a/pym/portage/tests/resolver/ResolverPlayground.py
+++ b/pym/portage/tests/resolver/ResolverPlayground.py
@@ -3,6 +3,7 @@
 
 from itertools import permutations
 import shutil
+import sys
 import tempfile
 import portage
 from portage import os
@@ -24,6 +25,9 @@ from _emerge.create_depgraph_params import create_depgraph_params
 from _emerge.depgraph import backtrack_depgraph
 from _emerge.RootConfig import RootConfig
 
+if sys.hexversion >= 0x3000000:
+	basestring = str
+
 class ResolverPlayground(object):
 	"""
 	This class helps to create the necessary files on disk and
@@ -470,6 +474,7 @@ class ResolverPlaygroundTestCase(object):
 	def __init__(self, request, **kwargs):
 		self.all_permutations = kwargs.pop("all_permutations", False)
 		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)
 
 		if self.all_permutations:
@@ -509,13 +514,51 @@ class ResolverPlaygroundTestCase(object):
 						got = new_got
 					if expected:
 						new_expected = []
-						for cpv in expected:
-							a = Atom("="+cpv, allow_repo=True)
-							new_expected.append(a.cpv)
+						for obj in expected:
+							if isinstance(obj, basestring):
+								a = Atom("="+obj, allow_repo=True)
+								new_expected.append(a.cpv)
+								continue
+							new_expected.append(set())
+							for cpv in obj:
+								a = Atom("="+cpv, allow_repo=True)
+								new_expected[-1].add(a.cpv)
 						expected = new_expected
 				if self.ignore_mergelist_order and got is not None:
 					got = set(got)
 					expected = set(expected)
+
+				if self.ambigous_merge_order and got:
+					expected_stack = list(reversed(expected))
+					got_stack = list(reversed(got))
+					new_expected = []
+					while got_stack and expected_stack:
+						got_token = got_stack.pop()
+						expected_obj = expected_stack.pop()
+						if isinstance(expected_obj, basestring):
+							new_expected.append(got_token)
+							continue
+						expected_obj = set(expected_obj)
+						try:
+							expected_obj.remove(got_token)
+						except KeyError:
+							# 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:
+								expected_obj.remove(got_token)
+							except KeyError:
+								match = False
+								break
+							new_expected.append(got_token)
+						if not match:
+							# result doesn't match, so stop early
+							break
+					expected = new_expected
+
 			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
new file mode 100644
index 0000000..ada9e73
--- /dev/null
+++ b/pym/portage/tests/resolver/test_merge_order.py
@@ -0,0 +1,45 @@
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import (ResolverPlayground,
+	ResolverPlaygroundTestCase)
+
+class MergeOrderTestCase(TestCase):
+
+	def testMergeOrder(self):
+		ebuilds = {
+			"app-misc/circ-runtime-a-1": {
+				"RDEPEND": "app-misc/circ-runtime-b",
+			},
+			"app-misc/circ-runtime-b-1": {
+				"RDEPEND": "app-misc/circ-runtime-a",
+			},
+			"app-misc/some-app-a-1": {
+				"RDEPEND": "app-misc/circ-runtime-a app-misc/circ-runtime-b",
+			},
+		}
+
+		installed = {
+		}
+
+		test_cases = (
+			ResolverPlaygroundTestCase(
+				["app-misc/some-app-a"],
+				success = True,
+				ambigous_merge_order = True,
+				mergelist = [("app-misc/circ-runtime-a-1", "app-misc/circ-runtime-b-1"), "app-misc/some-app-a-1"]),
+			ResolverPlaygroundTestCase(
+				["app-misc/some-app-a"],
+				success = True,
+				ambigous_merge_order = True,
+				mergelist = [("app-misc/circ-runtime-b-1", "app-misc/circ-runtime-a-1"), "app-misc/some-app-a-1"]),
+		)
+
+		playground = ResolverPlayground(ebuilds=ebuilds, installed=installed)
+		try:
+			for test_case in test_cases:
+				playground.run_TestCase(test_case)
+				self.assertEqual(test_case.test_success, True, test_case.fail_msg)
+		finally:
+			playground.cleanup()



             reply	other threads:[~2011-05-21  0:51 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-21  0:51 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-03-04 21:05 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/ Michał Górny
2018-02-26 22:07 Michał Górny
2017-12-16  3:16 Zac Medico
2016-06-26 23:51 Zac Medico
2016-04-29 17:24 Brian Dolbec
2014-09-19  8:52 Zac Medico
2014-09-16  6:35 Brian Dolbec
2014-02-24 20:03 Sebastian Luther
2014-01-07 20:40 Arfrever Frehtes Taifersar Arahesis
2014-01-07 19:06 Arfrever Frehtes Taifersar Arahesis
2013-12-05 21:51 Arfrever Frehtes Taifersar Arahesis
2013-11-27  7:44 Mike Frysinger
2013-11-27  3:24 Mike Frysinger
2013-11-26 15:11 Brian Dolbec
2013-11-26 13:50 Brian Dolbec
2013-08-22  0:46 Zac Medico
2013-07-30  2:13 Zac Medico
2013-03-04 23:37 Zac Medico
2013-02-14  1:20 Zac Medico
2013-02-12  3:03 Zac Medico
2013-02-12  1:36 Zac Medico
2012-10-26 17:25 Zac Medico
2012-10-26  6:31 Zac Medico
2012-10-26  3:44 Zac Medico
2012-09-26  2:38 Zac Medico
2012-09-26  2:36 Zac Medico
2012-09-26  0:52 Zac Medico
2012-09-25  3:30 Zac Medico
2012-06-23 21:53 Zac Medico
2012-06-21 22:32 Zac Medico
2012-06-20 10:06 Zac Medico
2012-06-20  9:53 Zac Medico
2012-06-14  0:24 Zac Medico
2012-05-13  6:23 Zac Medico
2011-12-11  0:22 Zac Medico
2011-11-07 21:38 Zac Medico
2011-10-02  2:14 Zac Medico
2011-09-22 19:07 Zac Medico
2011-09-22 18:19 Zac Medico
2011-09-18 20:08 Zac Medico
2011-09-11 18:50 Zac Medico
2011-09-05 22:44 Zac Medico
2011-08-29  6:19 Zac Medico
2011-06-04  3:08 Zac Medico
2011-05-30 23:44 Zac Medico
2011-05-30 22:58 Zac Medico
2011-05-23  5:59 Zac Medico
2011-05-23  0:46 Zac Medico
2011-05-22 22:01 Zac Medico
2011-05-22 21:01 Zac Medico
2011-05-22 20:36 Zac Medico
2011-05-22 20:03 Zac Medico
2011-05-22 19:44 Zac Medico
2011-05-22 17:03 Zac Medico
2011-05-22  9:05 Zac Medico
2011-05-21 22:37 Zac Medico
2011-05-21 22:17 Zac Medico
2011-05-21 10:34 Zac Medico
2011-05-21 10:30 Zac Medico
2011-05-21  9:21 Zac Medico
2011-05-21  9:11 Zac Medico
2011-05-21  8:47 Zac Medico
2011-05-21  4:15 Zac Medico
2011-05-21  4:02 Zac Medico
2011-05-21  3:30 Zac Medico
2011-05-21  1:17 Zac Medico
2011-05-21  1:13 Zac Medico
2011-05-21  1:01 Zac Medico
2011-05-17 20:34 Zac Medico
2011-05-04 17:36 Zac Medico
2011-02-17 10:43 Zac Medico
2011-02-13 17:35 Zac Medico
2011-02-13 13:01 Zac Medico
2011-02-13 11:35 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=286326e79fcc3b7246863f12c4d7376c9e06a673.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox