summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pym/portage')
-rw-r--r--pym/portage/tests/resolver/ResolverPlayground.py26
-rw-r--r--pym/portage/tests/resolver/test_autounmask.py131
-rw-r--r--pym/portage/tests/resolver/test_eapi.py6
-rw-r--r--pym/portage/tests/resolver/test_simple.py4
4 files changed, 155 insertions, 12 deletions
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
index a9954fef..3740f831 100644
--- a/pym/portage/tests/resolver/ResolverPlayground.py
+++ b/pym/portage/tests/resolver/ResolverPlayground.py
@@ -14,6 +14,7 @@ from portage.package.ebuild.config import config
from portage.sets import load_default_config
from portage.versions import catsplit
+from _emerge.Blocker import Blocker
from _emerge.create_depgraph_params import create_depgraph_params
from _emerge.depgraph import backtrack_depgraph
from _emerge.RootConfig import RootConfig
@@ -183,19 +184,30 @@ class ResolverPlayground(object):
# Add a fake _test_ option that can be used for
# conditional test code.
myopts["_test_"] = True
-
+
portage.util.noiselimit = -2
myparams = create_depgraph_params(myopts, myaction)
success, mydepgraph, favorites = backtrack_depgraph(
self.settings, self.trees, myopts, myparams, myaction, myfiles, None)
+ result = ResolverPlaygroundResult(success, mydepgraph, favorites)
portage.util.noiselimit = 0
- if success:
- mergelist = [x.cpv for x in mydepgraph._dynamic_config._serialized_tasks_cache]
- return True, mergelist
- else:
- #TODO: Use mydepgraph.display_problems() to return a useful error message
- return False, None
+ return result
def cleanup(self):
shutil.rmtree(self.root)
+
+class ResolverPlaygroundResult(object):
+ def __init__(self, success, mydepgraph, favorites):
+ self.success = success
+ self.depgraph = mydepgraph
+ self.favorites = favorites
+ self.mergelist = None
+
+ if self.depgraph._dynamic_config._serialized_tasks_cache is not None:
+ self.mergelist = []
+ for x in self.depgraph._dynamic_config._serialized_tasks_cache:
+ if isinstance(x, Blocker):
+ self.mergelist.append(x.atom)
+ else:
+ self.mergelist.append(x.cpv)
diff --git a/pym/portage/tests/resolver/test_autounmask.py b/pym/portage/tests/resolver/test_autounmask.py
new file mode 100644
index 00000000..944e5485
--- /dev/null
+++ b/pym/portage/tests/resolver/test_autounmask.py
@@ -0,0 +1,131 @@
+# Copyright 2010 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
+
+class AutounmaskTestCase(TestCase):
+
+ def testAutounmask(self):
+ ebuilds = {
+ #ebuilds to test use changes
+ "dev-libs/A-1": { "SLOT": 1, "DEPEND": "dev-libs/B[foo]", "EAPI": 2},
+ "dev-libs/A-2": { "SLOT": 2, "DEPEND": "dev-libs/B[bar]", "EAPI": 2},
+ "dev-libs/B-1": { "DEPEND": "foo? ( dev-libs/C ) bar? ( dev-libs/D )", "IUSE": "foo bar"},
+ "dev-libs/C-1": {},
+ "dev-libs/D-1": {},
+
+ #ebuilds to test keyword changes
+ "app-misc/Z-1": { "KEYWORDS": "~x86", "DEPEND": "app-misc/Y" },
+ "app-misc/Y-1": { "KEYWORDS": "~x86" },
+ "app-misc/W-1": {},
+ "app-misc/W-2": { "KEYWORDS": "~x86" },
+ "app-misc/V-1": { "KEYWORDS": "~x86", "DEPEND": ">=app-misc/W-2"},
+
+ #ebuilds for mixed test for || dep handling
+ "sci-libs/K-1": { "DEPEND": " || ( sci-libs/L[bar] || ( sci-libs/M sci-libs/P ) )", "EAPI": 2},
+ "sci-libs/K-2": { "DEPEND": " || ( sci-libs/L[bar] || ( sci-libs/P sci-libs/M ) )", "EAPI": 2},
+ "sci-libs/K-3": { "DEPEND": " || ( sci-libs/M || ( sci-libs/L[bar] sci-libs/P ) )", "EAPI": 2},
+ "sci-libs/K-4": { "DEPEND": " || ( sci-libs/M || ( sci-libs/P sci-libs/L[bar] ) )", "EAPI": 2},
+ "sci-libs/K-5": { "DEPEND": " || ( sci-libs/P || ( sci-libs/L[bar] sci-libs/M ) )", "EAPI": 2},
+ "sci-libs/K-6": { "DEPEND": " || ( sci-libs/P || ( sci-libs/M sci-libs/L[bar] ) )", "EAPI": 2},
+ "sci-libs/K-7": { "DEPEND": " || ( sci-libs/M sci-libs/L[bar] )", "EAPI": 2},
+ "sci-libs/K-8": { "DEPEND": " || ( sci-libs/L[bar] sci-libs/M )", "EAPI": 2},
+
+ "sci-libs/L-1": { "IUSE": "bar" },
+ "sci-libs/M-1": { "KEYWORDS": "~x86" },
+ "sci-libs/P-1": { },
+
+ #ebuilds to conflicting use changes
+ "net-www/G-1": { "DEPEND": "net-www/I[foo]", "EAPI": 2 },
+ "net-www/H-1": { "DEPEND": "net-www/I[-foo]", "EAPI": 2 },
+ "net-www/I-1": { "IUSE": "foo" },
+ "net-www/J-1": { "DEPEND": "|| ( net-www/G net-www/H )" },
+ "net-www/J-2": { "DEPEND": "|| ( net-www/H net-www/G )" },
+ "net-www/K-1": { "DEPEND": "!!net-www/G", "EAPI": 2 },
+ }
+
+ requests = (
+ #Test USE changes.
+ #The simple case.
+
+ (["dev-libs/A:1"], {"--autounmask": "n"}, None, False, None),
+ (["dev-libs/A:1"], {"--autounmask": True}, None, False, \
+ ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"]),
+
+ #Make sure we restart if needed.
+
+ (["dev-libs/B", "dev-libs/A:1"], {"--autounmask": True}, None, False, \
+ ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"]),
+ (["dev-libs/A:1", "dev-libs/B"], {"--autounmask": True}, None, False, \
+ ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"]),
+ (["dev-libs/A:1", "dev-libs/A:2"], {"--autounmask": True}, None, False, \
+ ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"]),
+ (["dev-libs/B", "dev-libs/A:1", "dev-libs/A:2"], {"--autounmask": True}, None, False, \
+ ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"]),
+ (["dev-libs/A:1", "dev-libs/B", "dev-libs/A:2"], {"--autounmask": True}, None, False, \
+ ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"]),
+ (["dev-libs/A:1", "dev-libs/A:2", "dev-libs/B"], {"--autounmask": True}, None, False, \
+ ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"]),
+
+ #Test keywording.
+ #The simple case.
+
+ (["app-misc/Z"], {"--autounmask": "n"}, None, False, None),
+ (["app-misc/Z"], {"--autounmask": True}, None, False, \
+ ["app-misc/Y-1", "app-misc/Z-1"]),
+
+ #Make sure that the backtracking for slot conflicts handles our mess.
+
+ (["=app-misc/V-1", "app-misc/W"], {"--autounmask": True}, None, False, \
+ ["app-misc/W-2", "app-misc/V-1"]),
+ (["app-misc/W", "=app-misc/V-1"], {"--autounmask": True}, None, False, \
+ ["app-misc/W-2", "app-misc/V-1"]),
+
+ #Mixed testing
+ #Make sure we don't change use for something in a || dep if there is another choice
+ #that needs no change.
+
+ (["=sci-libs/K-1"], {"--autounmask": True}, None, True, \
+ ["sci-libs/P-1", "sci-libs/K-1"]),
+ (["=sci-libs/K-2"], {"--autounmask": True}, None, True, \
+ ["sci-libs/P-1", "sci-libs/K-2"]),
+ (["=sci-libs/K-3"], {"--autounmask": True}, None, True, \
+ ["sci-libs/P-1", "sci-libs/K-3"]),
+ (["=sci-libs/K-4"], {"--autounmask": True}, None, True, \
+ ["sci-libs/P-1", "sci-libs/K-4"]),
+ (["=sci-libs/K-5"], {"--autounmask": True}, None, True, \
+ ["sci-libs/P-1", "sci-libs/K-5"]),
+ (["=sci-libs/K-6"], {"--autounmask": True}, None, True, \
+ ["sci-libs/P-1", "sci-libs/K-6"]),
+
+ #Make sure we prefer use changes over keyword changes.
+ (["=sci-libs/K-7"], {"--autounmask": True}, None, False, \
+ ["sci-libs/L-1", "sci-libs/K-7"]),
+ (["=sci-libs/K-8"], {"--autounmask": True}, None, False, \
+ ["sci-libs/L-1", "sci-libs/K-8"]),
+
+ #Testing conflict bahviour
+ (["=net-www/G-1", "=net-www/H-1"], {"--autounmask": True}, None, False, None),
+ #Some of the following tests don't work because we are not able to take back
+ #changes that later on turn out to be not necessary, because the package
+ #that induced the change gets masked.
+ #~ (["=net-www/J-1", "=net-www/K-1"], {"--autounmask": True}, None, True, \
+ #~ ["net-www/I-1", "net-www/H-1", "net-www/J-1", "net-www/K-1"] ),
+ (["=net-www/J-2", "=net-www/K-1"], {"--autounmask": True}, None, True, \
+ ["net-www/I-1", "net-www/K-1", "net-www/H-1", "net-www/J-2", ] ),
+ #~ (["=net-www/K-1", "=net-www/J-1"], {"--autounmask": True}, None, True, \
+ #~ ["net-www/I-1", "net-www/H-1", "net-www/J-1", "net-www/K-1"] ),
+ (["=net-www/K-1", "=net-www/J-2"], {"--autounmask": True}, None, True, \
+ ["net-www/I-1", "net-www/K-1", "net-www/H-1", "net-www/J-2", ] ),
+ )
+
+ playground = ResolverPlayground(ebuilds=ebuilds)
+ try:
+ for atoms, options, action, \
+ expected_result, expected_mergelist in requests:
+ result = playground.run(atoms, options, action)
+ self.assertEqual((result.success, result.mergelist),
+ (expected_result, expected_mergelist))
+ finally:
+ playground.cleanup()
diff --git a/pym/portage/tests/resolver/test_eapi.py b/pym/portage/tests/resolver/test_eapi.py
index 19c7b219..d9f34f43 100644
--- a/pym/portage/tests/resolver/test_eapi.py
+++ b/pym/portage/tests/resolver/test_eapi.py
@@ -4,7 +4,7 @@
from portage.tests import TestCase
from portage.tests.resolver.ResolverPlayground import ResolverPlayground
-class SimpleResolverTestCase(TestCase):
+class EAPITestCase(TestCase):
def testEAPI(self):
ebuilds = {
@@ -95,8 +95,8 @@ class SimpleResolverTestCase(TestCase):
try:
for atoms, options, action, \
expected_result, expected_mergelist in requests:
- success, mergelist = playground.run(atoms, options, action)
- self.assertEqual((success, mergelist),
+ result = playground.run(atoms, options, action)
+ self.assertEqual((result.success, result.mergelist),
(expected_result, expected_mergelist))
finally:
playground.cleanup()
diff --git a/pym/portage/tests/resolver/test_simple.py b/pym/portage/tests/resolver/test_simple.py
index 0e77c9e6..ef19abe1 100644
--- a/pym/portage/tests/resolver/test_simple.py
+++ b/pym/portage/tests/resolver/test_simple.py
@@ -27,8 +27,8 @@ class SimpleResolverTestCase(TestCase):
try:
for atoms, options, action, \
expected_result, expected_mergelist in requests:
- success, mergelist = playground.run(atoms, options, action)
- self.assertEqual((success, mergelist),
+ result = playground.run(atoms, options, action)
+ self.assertEqual((result.success, result.mergelist),
(expected_result, expected_mergelist))
finally:
playground.cleanup()