Skip to content

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
merged 25 commits into from
Feb 4, 2025

Conversation

rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Feb 3, 2025

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 rickeylev force-pushed the refactor.rule.builder branch from c304268 to e11caf3 Compare February 3, 2025 16:32
@rickeylev rickeylev force-pushed the refactor.rule.builder branch from 12c254e to 5639c0c Compare February 4, 2025 05:29
@rickeylev rickeylev force-pushed the refactor.rule.builder branch from 5639c0c to 7216be3 Compare February 4, 2025 05:43
@rickeylev rickeylev marked this pull request as ready for review February 4, 2025 05:50
@rickeylev rickeylev requested a review from aignas as a code owner February 4, 2025 05:50
@rickeylev 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
4 checks passed
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