Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/tests: subsystems can't declare dependencies on non-globally-scoped subsystems #5456

Merged

Conversation

cosmicexplorer
Copy link
Contributor

@cosmicexplorer cosmicexplorer commented Feb 12, 2018

Problem

Subsystems haven't been able to declare dependencies on other scoped subsystems, just global instances. If you try to do, e.g. from the new tests:

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

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

You'll see:

...
>       for dependency in subsystem.subsystem_dependencies():
                     E       AttributeError: 'SubsystemDependency' object has no attribute 'subsystem_dependencies'
                     
                     src/python/pants/subsystem/subsystem.py:112: AttributeError
                     ======= 1 failed, 9 passed in 0.07 seconds =======
...

Solution

The stacktrace helpfully gives the exact issue clearly -- Subsystem.closure() was not using subsystem_dependencies_iter(), and could therefore receive either a Subsystem or a SubsystemDependency. It has been assuming all dependencies were just Subsystems, which I noticed when I tried to declare a dependency on a scoped subsystem.

Using subsystem_dependencies_iter() and extracting the subsystem_cls from the SubsystemDependency object now allows users to declare dependencies on non-globally-scoped subsystems, which is pretty neat.

Copy link
Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@benjyw benjyw merged commit 569f14c into pantsbuild:master Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants