FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

refactor: expose base rule construction via builders to allow customization for testing by rickeylev · Pull Request #2600 · bazel-contrib/rules_python · GitHub

refactor: expose base rule construction via builders to allow customization for testing - #2600

Merged
rickeylev merged 25 commits into
bazel-contrib:mainfrom
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:mainfrom
rickeylev:refactor.rule.builder

Conversation

rickeylev commented Feb 3, 2025
edited
Loading

Copy link
Copy Markdown
Collaborator

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

rickeylev force-pushed the refactor.rule.builder branch from c304268 to e11caf3 Compare February 3, 2025 16:32
rickeylev force-pushed the refactor.rule.builder branch from 12c254e to 5639c0c Compare February 4, 2025 05:29
rickeylev force-pushed the refactor.rule.builder branch from 5639c0c to 7216be3 Compare February 4, 2025 05:43
rickeylev marked this pull request as ready for review February 4, 2025 05:50
rickeylev requested a review from aignas as a code owner February 4, 2025 05:50
rickeylev added this pull request to the merge queue Feb 4, 2025
Merged via the queue into bazel-contrib:main with commit 81c6798 Feb 4, 2025
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
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


Back | FazBrowse Home | New Git URL