use of com.google.devtools.build.lib.packages.RequiredProviders in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method aspectRequiredAspectProvidersEmpty.
@Test
public void aspectRequiredAspectProvidersEmpty() throws Exception {
evalAndExport("def _impl(target, ctx):", " pass", "my_aspect = aspect(_impl, required_aspect_providers=[])");
SkylarkAspect myAspect = (SkylarkAspect) lookup("my_aspect");
RequiredProviders requiredProviders = myAspect.getDefinition(AspectParameters.EMPTY).getRequiredProvidersForAspects();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.ANY)).isFalse();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.EMPTY)).isFalse();
}
use of com.google.devtools.build.lib.packages.RequiredProviders in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method aspectRequiredAspectProvidersAlternatives.
@Test
public void aspectRequiredAspectProvidersAlternatives() throws Exception {
evalAndExport("def _impl(target, ctx):", " pass", "cc = provider()", "my_aspect = aspect(_impl, required_aspect_providers=[['java'], [cc]])");
SkylarkAspect myAspect = (SkylarkAspect) lookup("my_aspect");
RequiredProviders requiredProviders = myAspect.getDefinition(AspectParameters.EMPTY).getRequiredProvidersForAspects();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.ANY)).isTrue();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.EMPTY)).isFalse();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.builder().addSkylark("java").build())).isTrue();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.builder().addSkylark(declared("cc")).build())).isTrue();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.builder().addSkylark("prolog").build())).isFalse();
}
use of com.google.devtools.build.lib.packages.RequiredProviders in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method aspectRequiredAspectProvidersDefault.
@Test
public void aspectRequiredAspectProvidersDefault() throws Exception {
evalAndExport("def _impl(target, ctx):", " pass", "my_aspect = aspect(_impl)");
SkylarkAspect myAspect = (SkylarkAspect) lookup("my_aspect");
RequiredProviders requiredProviders = myAspect.getDefinition(AspectParameters.EMPTY).getRequiredProvidersForAspects();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.ANY)).isFalse();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.EMPTY)).isFalse();
}
use of com.google.devtools.build.lib.packages.RequiredProviders in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method aspectRequiredAspectProvidersSingle.
@Test
public void aspectRequiredAspectProvidersSingle() throws Exception {
evalAndExport("def _impl(target, ctx):", " pass", "cc = provider()", "my_aspect = aspect(_impl, required_aspect_providers=['java', cc])");
SkylarkAspect myAspect = (SkylarkAspect) lookup("my_aspect");
RequiredProviders requiredProviders = myAspect.getDefinition(AspectParameters.EMPTY).getRequiredProvidersForAspects();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.ANY)).isTrue();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.EMPTY)).isFalse();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.builder().addSkylark(declared("cc")).addSkylark("java").build())).isTrue();
assertThat(requiredProviders.isSatisfiedBy(AdvertisedProviderSet.builder().addSkylark("cc").build())).isFalse();
}
Aggregations