From 07f774d36f82d3b35b6825434bb4a3f20218f2a2 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Tue, 8 Apr 2008 16:14:53 +0100 Subject: [PATCH] Bugfix: multiple dependencies on a single library didn't work If the same library was required by two components within a single process, the solver would exit early with None, which was interpreted as False (i.e. failure to choose a set of versions). This also affects libraries that depend on themselves. Reported by Sladi. --- tests/Recursive.xml | 13 +++++++++++++ tests/testsolver.py | 14 ++++++++++++++ zeroinstall/injector/solver.py | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/Recursive.xml diff --git a/tests/Recursive.xml b/tests/Recursive.xml new file mode 100644 index 0000000..2fe259f --- /dev/null +++ b/tests/Recursive.xml @@ -0,0 +1,13 @@ + + + Recursive + Recursive + Recursive + + + + + + + diff --git a/tests/testsolver.py b/tests/testsolver.py index 0a3e813..c882452 100755 --- a/tests/testsolver.py +++ b/tests/testsolver.py @@ -58,6 +58,20 @@ class TestSolver(BaseTest): assert len(s.details) == 2 assert s.details[foo] == [(foo_src._main_feed.implementations['sha1=234'], None), (foo._main_feed.implementations['sha1=123'], 'Unsupported machine type')] assert s.details[compiler] == [(compiler._main_feed.implementations['sha1=345'], None)] + + def testRecursive(self): + s = solver.DefaultSolver(model.network_full, iface_cache, Stores()) + + foo = iface_cache.get_interface('http://foo/Recursive.xml') + reader.update(foo, 'Recursive.xml') + + binary_arch = arch.Architecture({None: 1}, {None: 1}) + s.record_details = True + s.solve('http://foo/Recursive.xml', binary_arch) + assert s.ready + + assert len(s.details) == 1 + assert s.details[foo] == [(foo._main_feed.implementations['sha1=abc'], None)] suite = unittest.makeSuite(TestSolver) diff --git a/zeroinstall/injector/solver.py b/zeroinstall/injector/solver.py index fd11920..e08bca5 100644 --- a/zeroinstall/injector/solver.py +++ b/zeroinstall/injector/solver.py @@ -83,7 +83,7 @@ class DefaultSolver(Solver): if dep.restrictions: warn("Interface requested twice; I've already chosen an implementation " "of '%s' but there are more restrictions! Ignoring the second set.", iface) - return + return ready self.selections[iface] = None # Avoid cycles assert iface not in restrictions -- 2.11.4.GIT