What rules are available by default in a RuleRunne...
# plugins
g
What rules are available by default in a RuleRunner? None? Some? For context, I'm writing a unit test which has to go through a target generator. The target generator works outside the test, but inside the test it fails with:
Copy code
E         No installed rules return the type GenerateCargoTargetsRequest, and it was not provided by potential callers of @rule(pants_cargo_porcelain.target_types:172:generate_cargo_generated_target(GenerateCargoTargetsRequest, RustSubsystem, RustupTool) -> GeneratedTargets, gets=[Get(SourceFiles, [SourceFilesRequest]), Get(RustToolchain, [RustToolchainRequest]), Get(ProcessResult, [CargoProcessRequest])]).
My runner is dumb as rocks:
Copy code
rule_runner = RuleRunner(
        rules=[
            *register.rules(),
            *clippy_register.rules(),
            QueryRule(Partitions, [CargoClippyRequest.PartitionRequest]),
            # QueryRule(LintResult, [CargoClippyRequest.Batch]),
        ],
        target_types=register.target_types(),
    )
Which at this point is everything in the plugin.
register.rules()
bundles the following from my target types.
Copy code
def rules():
    return [
        *collect_rules(),
        UnionRule(GenerateTargetsRequest, GenerateCargoTargetsRequest),
    ]
But I'm guessing this happens "one step up" where something has to do a union lookup...
Just to double-check, this rule is included in the first rule bundle I register:
Copy code
UnionRule(union_base=<class 'pants.engine.target.GenerateTargetsRequest'>, union_member=<class'pants_cargo_porcelain.target_types.GenerateCargoTargetsRequest'>)
c
(along with the
*rules
which comes from all loaded backends/plugins)
Oh, and two backends are always loaded as well..
so what ever rules are provided by those backends will also be available
g
Thank you, great links. I ended up just throwing rule bundles onto it until it worked. As with all rule issues; the issue was somewhere else - I needed to add
external_tool.rules()
and
source_files.rules()
.
👍 1