bazelbuild / rules_testing

Starlark testing framework and utility libraries
https://rules-testing.readthedocs.io/
Apache License 2.0
21 stars 5 forks source link

Add support for provider maps to rules_testing #83

Closed copybara-service[bot] closed 7 months ago

copybara-service[bot] commented 7 months ago

Add support for provider maps to rules_testing

Currently, If you are testing a custom provider, the API requires you to write: env.expect.that_target(targets.foo).provider(FooInfo, factory=FooFactory)... env.expect.that_target(targets.foo).provider(BarInfo, factory=BarFactory)...

This can get very tedious, and more importantly, is not very safe, since you can write: env.expect.that_target(targets.foo).provider(FooInfo, factory=FooFactory)... env.expect.that_target(targets.foo).provider(BarInfo, factory=FooFactory)...

Additionally, custom types are always rendered as "".

To solve this, we add the ability to directly specify a list of factories for custom types in your test.

analysis_test( ..., provider_factories = [struct(type = FooInfo, name = "FooInfo", factory = FooFactory)] )

google-cla[bot] commented 7 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.