From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QNaQ2-0003H6-CC for garchives@archives.gentoo.org; Sat, 21 May 2011 00:51:50 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F0EA71C009; Sat, 21 May 2011 00:51:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id ACA311C009 for ; Sat, 21 May 2011 00:51:39 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 178DB1B4005 for ; Sat, 21 May 2011 00:51:39 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 27DC18001E for ; Sat, 21 May 2011 00:51:38 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <286326e79fcc3b7246863f12c4d7376c9e06a673.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/tests/resolver/ResolverPlayground.py pym/portage/tests/resolver/test_merge_order.py X-VCS-Directories: pym/portage/tests/resolver/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 286326e79fcc3b7246863f12c4d7376c9e06a673 Date: Sat, 21 May 2011 00:51:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: a14434c295ea8fbbad0a3efdc00fe239 commit: 286326e79fcc3b7246863f12c4d7376c9e06a673 Author: Zac Medico gentoo org> AuthorDate: Sat May 21 00:51:09 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat May 21 00:51:09 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D286326e7 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/porta= ge/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 @@ =20 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_depgr= aph_params from _emerge.depgraph import backtrack_depgraph from _emerge.RootConfig import RootConfig =20 +if sys.hexversion >=3D 0x3000000: + basestring =3D 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 =3D kwargs.pop("all_permutations", False) self.ignore_mergelist_order =3D kwargs.pop("ignore_mergelist_order", F= alse) + self.ambigous_merge_order =3D kwargs.pop("ambigous_merge_order", False= ) self.check_repo_names =3D kwargs.pop("check_repo_names", False) =20 if self.all_permutations: @@ -509,13 +514,51 @@ class ResolverPlaygroundTestCase(object): got =3D new_got if expected: new_expected =3D [] - for cpv in expected: - a =3D Atom("=3D"+cpv, allow_repo=3DTrue) - new_expected.append(a.cpv) + for obj in expected: + if isinstance(obj, basestring): + a =3D Atom("=3D"+obj, allow_repo=3DTrue) + new_expected.append(a.cpv) + continue + new_expected.append(set()) + for cpv in obj: + a =3D Atom("=3D"+cpv, allow_repo=3DTrue) + new_expected[-1].add(a.cpv) expected =3D new_expected if self.ignore_mergelist_order and got is not None: got =3D set(got) expected =3D set(expected) + + if self.ambigous_merge_order and got: + expected_stack =3D list(reversed(expected)) + got_stack =3D list(reversed(got)) + new_expected =3D [] + while got_stack and expected_stack: + got_token =3D got_stack.pop() + expected_obj =3D expected_stack.pop() + if isinstance(expected_obj, basestring): + new_expected.append(got_token) + continue + expected_obj =3D 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 =3D True + while got_stack and expected_obj: + got_token =3D got_stack.pop() + try: + expected_obj.remove(got_token) + except KeyError: + match =3D False + break + new_expected.append(got_token) + if not match: + # result doesn't match, so stop early + break + expected =3D new_expected + elif key in ("unstable_keywords", "needed_p_mask_changes") and expect= ed is not None: expected =3D set(expected) =20 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 (ResolverPlaygroun= d, + ResolverPlaygroundTestCase) + +class MergeOrderTestCase(TestCase): + + def testMergeOrder(self): + ebuilds =3D { + "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 =3D { + } + + test_cases =3D ( + ResolverPlaygroundTestCase( + ["app-misc/some-app-a"], + success =3D True, + ambigous_merge_order =3D True, + mergelist =3D [("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 =3D True, + ambigous_merge_order =3D True, + mergelist =3D [("app-misc/circ-runtime-b-1", "app-misc/circ-runtime-= a-1"), "app-misc/some-app-a-1"]), + ) + + playground =3D ResolverPlayground(ebuilds=3Debuilds, installed=3Dinsta= lled) + 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()