-
-
Notifications
You must be signed in to change notification settings - Fork 588
refactor: expose base rule construction via builders to allow customization for testing #2600
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
Merged
rickeylev
merged 25 commits into
bazel-contrib:main
from
rickeylev:refactor.rule.builder
Feb 4, 2025
Merged
refactor: expose base rule construction via builders to allow customization for testing #2600
rickeylev
merged 25 commits into
bazel-contrib:main
from
rickeylev:refactor.rule.builder
Feb 4, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…o fix.venv.symlink.packaging
…o fix.venv.symlink.packaging
…o fix.venv.symlink.packaging
c304268
to
e11caf3
Compare
12c254e
to
5639c0c
Compare
5639c0c
to
7216be3
Compare
aignas
approved these changes
Feb 4, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The py_reconfig rules work by wrapping: The outer reconfig rule applies a transition, depends
on an inner py base rule, then jumps through various hoops to ensure it looks and acts
like the target it's wrapping.
This is error prone, incomplete, and annoying code to maintain. Phil recently discovered it wasn't properly propagating the output group, so he had to add that. I wasted time trying to fix a bug I thought was in it, but actually was working correctly. The logic within it is a bit hacky as it tries to emulate some of the platform-specific stuff for windows. Every time
py_reconfig gains something to transition on, there's numerous places to define, propagate,
and extract the pieces necessary to do it.
To fix this, make the py_reconfig rules not wrap an inner base py rule. Instead, they use the same underlying rule args that the base rules do. This lets them act directly as the rule they're designed to test.
Customization is done by capturing all the rule args in builder objects. The py_reconfig code constructs the same builder the base rules do, then modifies it as necessary (adding attributes, wrapping the base transition function). As a bonus, this sets some ground work to allow more easily defining derivative rules without having to copy/paste arbitrary parts of how the base rules are defined.
Work towards #1647