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
Port more tests from TestBase
to RuleRunner
#10704
Port more tests from TestBase
to RuleRunner
#10704
Conversation
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the diff size. I marked where there is anything of interest. This was a pretty routine change facilitated by PyCharm + find and replace.
@@ -3,192 +3,208 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now use 3 distinct RuleRunner
s rather than 1 TestBase
. This results in tighter rule graphs.
@@ -113,4 +114,4 @@ async def setup_pex_cli_process( | |||
|
|||
|
|||
def rules(): | |||
return [*collect_rules(), *pex_environment.rules()] | |||
return [*collect_rules(), *external_tool.rules(), *pex_environment.rules()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes test setup far more ergonomic.
@@ -262,4 +264,4 @@ async def two_step_pex_from_targets(req: TwoStepPexFromTargetsRequest) -> TwoSte | |||
|
|||
|
|||
def rules(): | |||
return collect_rules() | |||
return (*collect_rules(), *pex_rules(), *python_sources_rules()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes test setup far more ergonomic.
@@ -20,7 +20,6 @@ | |||
from pants.engine.target import FieldSet, Sources, Target, Targets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could have been unit tests the whole time. We don't use RuleRunner
because there's no reason to.
@@ -73,6 +73,7 @@ | |||
from pants.engine.unions import UnionMembership, UnionRule, union |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use a couple distinct RuleRunner
s here, more than we had TestBase
s. This results in tighter graphs.
from pants.testutil.test_base import TestBase | ||
|
||
|
||
class WorkspaceGoalSubsystem(GoalSubsystem): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class, and all the below rules / dataclasses, get inlined into the single unit test that use it. I figured this results in better namespacing.
class OptionsFingerprinterTest(TestBase): | ||
def setUp(self) -> None: | ||
super().setUp() | ||
self.options_fingerprinter = OptionsFingerprinter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of self.options_fingerprinter
, we now create a new OptionsFingerprinter()
every time we need it. Turns out, all the methods are really classmethods, even though they're marked as instance methods.
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
[ci skip-rust]
[ci skip-build-wheels]