summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2010-09-20 13:29:42 +0200
committerZac Medico <zmedico@gentoo.org>2010-09-20 08:11:38 -0700
commitd54430b4c2d2191d051930925e6029ec22c19baf (patch)
tree1d3ec3151ac4e07bdddd2273425692e03640a12c
parente1832018e84a75871c69e1d1c7779592014fa041 (diff)
downloadportage-d54430b4c2d2191d051930925e6029ec22c19baf.tar.gz
portage-d54430b4c2d2191d051930925e6029ec22c19baf.tar.bz2
portage-d54430b4c2d2191d051930925e6029ec22c19baf.zip
Tests: add resolver/test_output: Make sure we don't backtrace in the merge list printer
-rw-r--r--pym/_emerge/depgraph.py28
-rw-r--r--pym/portage/tests/resolver/ResolverPlayground.py2
-rw-r--r--pym/portage/tests/resolver/test_output.py88
3 files changed, 101 insertions, 17 deletions
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 29601562f..3670899de 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -411,7 +411,6 @@ class depgraph(object):
if not missed_updates:
return
- write = sys.stderr.write
backtrack_masked = []
for pkg, parent_atoms in missed_updates:
@@ -425,31 +424,29 @@ class depgraph(object):
backtrack_masked.append((pkg, parent_atoms))
continue
- write("\n!!! The following update has been skipped " + \
- "due to unsatisfied dependencies:\n\n")
+ writemsg("\n!!! The following update has been skipped " + \
+ "due to unsatisfied dependencies:\n\n", noiselevel=-1)
- write(str(pkg.slot_atom))
+ writemsg(str(pkg.slot_atom), noiselevel=-1)
if pkg.root != '/':
- write(" for %s" % (pkg.root,))
- write("\n")
+ writemsg(" for %s" % (pkg.root,), noiselevel=-1)
+ writemsg("\n", noiselevel=-1)
for parent, root, atom in parent_atoms:
self._show_unsatisfied_dep(root, atom, myparent=parent)
- write("\n")
+ writemsg("\n", noiselevel=-1)
if backtrack_masked:
# These are shown in abbreviated form, in order to avoid terminal
# flooding from mask messages as reported in bug #285832.
- write("\n!!! The following update(s) have been skipped " + \
+ writemsg("\n!!! The following update(s) have been skipped " + \
"due to unsatisfied dependencies\n" + \
- "!!! triggered by backtracking:\n\n")
+ "!!! triggered by backtracking:\n\n", noiselevel=-1)
for pkg, parent_atoms in backtrack_masked:
- write(str(pkg.slot_atom))
+ writemsg(str(pkg.slot_atom), noiselevel=-1)
if pkg.root != '/':
- write(" for %s" % (pkg.root,))
- write("\n")
-
- sys.stderr.flush()
+ writemsg(" for %s" % (pkg.root,), noiselevel=-1)
+ writemsg("\n", noiselevel=-1)
def _show_missed_update_slot_conflicts(self, missed_updates):
@@ -485,8 +482,7 @@ class depgraph(object):
msg.append("\n")
msg.append("\n")
- sys.stderr.write("".join(msg))
- sys.stderr.flush()
+ writemsg("".join(msg), noiselevel=-1)
def _show_slot_collision_notice(self):
"""Show an informational message advising the user to mask one of the
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
index 8d2a9fd3b..be1c29470 100644
--- a/pym/portage/tests/resolver/ResolverPlayground.py
+++ b/pym/portage/tests/resolver/ResolverPlayground.py
@@ -410,7 +410,6 @@ class ResolverPlayground(object):
def run(self, atoms, options={}, action=None):
options = options.copy()
options["--pretend"] = True
- options["--quiet"] = True
if self.debug:
options["--debug"] = True
@@ -432,6 +431,7 @@ class ResolverPlayground(object):
params = create_depgraph_params(options, action)
success, depgraph, favorites = backtrack_depgraph(
self.settings, self.trees, options, params, action, atoms, None)
+ depgraph._show_merge_list()
depgraph.display_problems()
result = ResolverPlaygroundResult(atoms, success, depgraph, favorites)
finally:
diff --git a/pym/portage/tests/resolver/test_output.py b/pym/portage/tests/resolver/test_output.py
new file mode 100644
index 000000000..34efe9c56
--- /dev/null
+++ b/pym/portage/tests/resolver/test_output.py
@@ -0,0 +1,88 @@
+# 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, ResolverPlaygroundTestCase
+
+class MergelistOutputTestCase(TestCase):
+
+ def testMergelistOutput(self):
+ """
+ This test doesn't check if the output is correct, but makes sure
+ that we don't backtrace somewhere in the output code.
+ """
+ ebuilds = {
+ "dev-libs/A-1": { "DEPEND": "dev-libs/B dev-libs/C", "IUSE": "+foo", "EAPI": 1 },
+ "dev-libs/B-1": { "DEPEND": "dev-libs/D", "IUSE": "foo +bar", "EAPI": 1 },
+ "dev-libs/C-1": { "DEPEND": "dev-libs/E", "IUSE": "foo bar" },
+ "dev-libs/D-1": { "IUSE": "" },
+ "dev-libs/E-1": {},
+
+ #reinstall for flags
+ "dev-libs/Z-1": { "IUSE": "+foo", "EAPI": 1 },
+ "dev-libs/Y-1": { "IUSE": "foo", "EAPI": 1 },
+ "dev-libs/X-1": {},
+ "dev-libs/W-1": { "IUSE": "+foo", "EAPI": 1 },
+ }
+
+ installed = {
+ "dev-libs/Z-1": { "USE": "", "IUSE": "foo" },
+ "dev-libs/Y-1": { "USE": "foo", "IUSE": "+foo", "EAPI": 1 },
+ "dev-libs/X-1": { "USE": "foo", "IUSE": "+foo", "EAPI": 1 },
+ "dev-libs/W-1": { },
+ }
+
+ option_cobos = (
+ (),
+ ("verbose",),
+ ("tree",),
+ ("tree", "unordered-display",),
+ ("verbose",),
+ ("verbose", "tree",),
+ ("verbose", "tree", "unordered-display",),
+ )
+
+ test_cases = []
+ for options in option_cobos:
+ testcase_opts = {}
+ for opt in options:
+ testcase_opts["--" + opt] = True
+
+ test_cases.append(ResolverPlaygroundTestCase(
+ ["dev-libs/A"],
+ options = testcase_opts,
+ success = True,
+ ignore_mergelist_order=True,
+ mergelist = ["dev-libs/D-1", "dev-libs/E-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"]))
+
+ test_cases.append(ResolverPlaygroundTestCase(
+ ["dev-libs/Z"],
+ options = testcase_opts,
+ success = True,
+ mergelist = ["dev-libs/Z-1"]))
+
+ test_cases.append(ResolverPlaygroundTestCase(
+ ["dev-libs/Y"],
+ options = testcase_opts,
+ success = True,
+ mergelist = ["dev-libs/Y-1"]))
+
+ test_cases.append(ResolverPlaygroundTestCase(
+ ["dev-libs/X"],
+ options = testcase_opts,
+ success = True,
+ mergelist = ["dev-libs/X-1"]))
+
+ test_cases.append(ResolverPlaygroundTestCase(
+ ["dev-libs/W"],
+ options = testcase_opts,
+ success = True,
+ mergelist = ["dev-libs/W-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()