Remove all calls to create_subsystem() in tests.
Review Request #4178 — Created Aug. 22, 2016 and submitted
|jsirois, mateor, nhoward_tw, zundel|
This is the first of several changes I have planned to
clean up how we create subsystem instances in tests.
Today it's chaos - we have at least three different ways (two
helper functions and via the test context). And these interact
in bad ways with each other, and with the creation of other
Optionables (such as Tasks). For example, one way may reset the
subsystem state before another has had a chance to work.
Furthermore, instantiating a subsystem instance directly
by providing it with its option values is not always
a well-defined operation. For example, some subsystems
depend on other subsystems, and this method skips initializing
those other subsystems entirely.
The best way to get a subsystem instance in a test is to
initialize that subsystem type via self.context(for_subsystems=...).
You can then also pass in options to set on the subsystem
and any of its dependencies. This way you can also control
whether you configure and use the global instance or some
It may seem a little clunkier, but this is usually what's
happening behind the scenes anyway, and at least this way
it's explicit, and any options conflicts are exposed early.
Future changes will remove the subsystem_instance() method too.
CI passes: https://travis-ci.org/pantsbuild/pants/builds/154237408
Thanks Mateo! Submitted based on Mateo's ShipIt, because I'm going on vacation in a few hours. But if other reviewers raise issues I'll address them when I return.