Merge "Iterate over provided elements first"
This commit is contained in:
commit
c8950dc13d
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import collections
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -84,11 +85,13 @@ def expand_dependencies(user_elements, elements_dir=None):
|
|||||||
including any transitive dependencies.
|
including any transitive dependencies.
|
||||||
"""
|
"""
|
||||||
final_elements = set(user_elements)
|
final_elements = set(user_elements)
|
||||||
check_queue = list(user_elements)
|
check_queue = collections.deque(user_elements)
|
||||||
provided = set()
|
provided = set()
|
||||||
|
|
||||||
while check_queue:
|
while check_queue:
|
||||||
element = check_queue.pop()
|
# bug #1303911 - run through the provided elements first to avoid
|
||||||
|
# adding unwanted dependencies and looking for virtual elements
|
||||||
|
element = check_queue.popleft()
|
||||||
if element in provided:
|
if element in provided:
|
||||||
continue
|
continue
|
||||||
deps = dependencies(element, elements_dir)
|
deps = dependencies(element, elements_dir)
|
||||||
|
@ -51,9 +51,17 @@ class TestElementDeps(testtools.TestCase):
|
|||||||
[],
|
[],
|
||||||
['virtual'])
|
['virtual'])
|
||||||
_populate_element(self.element_dir, 'requires_virtual', ['virtual'])
|
_populate_element(self.element_dir, 'requires_virtual', ['virtual'])
|
||||||
_populate_element(self.element_dir, 'virtual', [])
|
_populate_element(self.element_dir, 'virtual', ['extra_dependency'])
|
||||||
|
_populate_element(self.element_dir, 'extra_dependency', [])
|
||||||
_populate_element(self.element_dir, 'circular1', ['circular2'])
|
_populate_element(self.element_dir, 'circular1', ['circular2'])
|
||||||
_populate_element(self.element_dir, 'circular2', ['circular1'])
|
_populate_element(self.element_dir, 'circular2', ['circular1'])
|
||||||
|
_populate_element(self.element_dir,
|
||||||
|
'provides_new_virtual',
|
||||||
|
[],
|
||||||
|
['new_virtual'])
|
||||||
|
_populate_element(self.element_dir,
|
||||||
|
'requires_new_virtual',
|
||||||
|
['new_virtual'])
|
||||||
|
|
||||||
def test_non_transitive_deps(self):
|
def test_non_transitive_deps(self):
|
||||||
result = element_dependencies.expand_dependencies(
|
result = element_dependencies.expand_dependencies(
|
||||||
@ -90,7 +98,7 @@ class TestElementDeps(testtools.TestCase):
|
|||||||
|
|
||||||
def test_provide(self):
|
def test_provide(self):
|
||||||
result = element_dependencies.expand_dependencies(
|
result = element_dependencies.expand_dependencies(
|
||||||
['requires_virtual', 'provides_virtual'],
|
['provides_virtual', 'requires_virtual'],
|
||||||
elements_dir=self.element_dir)
|
elements_dir=self.element_dir)
|
||||||
self.assertEqual(set(['requires_virtual', 'provides_virtual']), result)
|
self.assertEqual(set(['requires_virtual', 'provides_virtual']), result)
|
||||||
|
|
||||||
@ -100,6 +108,13 @@ class TestElementDeps(testtools.TestCase):
|
|||||||
['virtual', 'provides_virtual'],
|
['virtual', 'provides_virtual'],
|
||||||
self.element_dir)
|
self.element_dir)
|
||||||
|
|
||||||
|
def test_provide_virtual_ordering(self):
|
||||||
|
result = element_dependencies.expand_dependencies(
|
||||||
|
['requires_new_virtual', 'provides_new_virtual'],
|
||||||
|
elements_dir=self.element_dir)
|
||||||
|
self.assertEqual(set(['requires_new_virtual', 'provides_new_virtual']),
|
||||||
|
result)
|
||||||
|
|
||||||
|
|
||||||
class TestElements(testtools.TestCase):
|
class TestElements(testtools.TestCase):
|
||||||
def test_depends_on_env(self):
|
def test_depends_on_env(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user