https://pantsbuild.org/ logo
#development
Title
# development
c

careful-address-89803

10/22/2022, 4:18 AM
hey folks, for testing, if I have a rule, I can test it with `rule_runner.request(...)`; is there something similar for a rule_helper?
I've found an instance of an ad-hoc wrapper rule, which you register in the RuleRunner:
Copy code
@rule
    async def run_rule(
        request: UniqueICsRequest, python_setup: PythonSetup
    ) -> InterpreterConstraints:
        ...
This works well enough, but is some extra boilerplate. Thoughts/opinions on constructing this automatically? so you could do something like:
Copy code
RuleRunner(
    rules=[
        ...
        CallableRuleHelper(_my_rule_helper),
    ],
    ...
)
To me, it feels similar to adding a QueryRule. An alternative I could see would be to make a parallel to
RuleRunner.request
that executes rule_helpers
h

happy-kitchen-89482

10/23/2022, 10:53 PM
@bitter-ability-32190 thoughts?
b

bitter-ability-32190

10/23/2022, 10:55 PM
It's not really a rule it's just an async function. Of wait but it has Gets... Idk I think @witty-crayon-22786 probably has a the most natural solution to this 😅
Having a helper which makes it callable like a normal rule doesn't sound bad to me 😄
w

witty-crayon-22786

10/25/2022, 4:45 PM
yea, it should be easy to do with the same
run_rule_with_mocks
code, since the way it executes is identical