Skip to content

Commit

Permalink
fix/tests: subsystems can't declare dependencies on non-globally-scop…
Browse files Browse the repository at this point in the history
…ed subsystems (#5456)
cosmicexplorer authored and benjyw committed Feb 12, 2018
1 parent 01a5b5c commit 569f14c
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
.factorypath
.python
.pydevproject
.pytest_cache/
build/
codegen/classes/
htmlcov/
4 changes: 2 additions & 2 deletions src/python/pants/subsystem/subsystem.py
Original file line number Diff line number Diff line change
@@ -104,8 +104,8 @@ def collect_subsystems(subsystem):
path.add(subsystem)
if subsystem not in known_subsystem_types:
known_subsystem_types.add(subsystem)
for dependency in subsystem.subsystem_dependencies():
collect_subsystems(dependency)
for dependency in subsystem.subsystem_dependencies_iter():
collect_subsystems(dependency.subsystem_cls)
path.remove(subsystem)

for subsystem_type in subsystem_types:
12 changes: 12 additions & 0 deletions tests/python/pants_test/subsystem/test_subsystem.py
Original file line number Diff line number Diff line change
@@ -28,6 +28,16 @@ class UninitializedSubsystem(Subsystem):
options_scope = 'uninitialized-scope'


class ScopedDependentSubsystem(Subsystem):
options_scope = 'scoped-dependent-subsystem'

@classmethod
def subsystem_dependencies(cls):
return super(ScopedDependentSubsystem, cls).subsystem_dependencies() + (
DummySubsystem.scoped(cls),
)


class SubsystemTest(unittest.TestCase):
def setUp(self):
DummySubsystem._options = DummyOptions()
@@ -52,6 +62,8 @@ class NoScopeSubsystem(Subsystem):

def test_closure_simple(self):
self.assertEqual({DummySubsystem}, Subsystem.closure((DummySubsystem,)))
self.assertEqual({DummySubsystem, ScopedDependentSubsystem},
Subsystem.closure((ScopedDependentSubsystem,)))

def test_closure_tree(self):
class SubsystemB(Subsystem):

0 comments on commit 569f14c

Please sign in to comment.