use of com.google.devtools.build.lib.packages.AspectDefinition in project bazel by bazelbuild.
the class AspectDefinitionTest method testNoConfigurationFragmentPolicySetup_HasNonNullPolicy.
@Test
public void testNoConfigurationFragmentPolicySetup_HasNonNullPolicy() throws Exception {
AspectDefinition noPolicy = new AspectDefinition.Builder(TEST_ASPECT_CLASS).build();
assertThat(noPolicy.getConfigurationFragmentPolicy()).isNotNull();
}
use of com.google.devtools.build.lib.packages.AspectDefinition in project bazel by bazelbuild.
the class AspectDefinitionTest method testRequiresHostConfigurationFragmentNames_PropagatedToConfigurationFragmentPolicy.
@Test
public void testRequiresHostConfigurationFragmentNames_PropagatedToConfigurationFragmentPolicy() throws Exception {
AspectDefinition requiresFragments = new AspectDefinition.Builder(TEST_ASPECT_CLASS).requiresHostConfigurationFragmentsBySkylarkModuleName(ImmutableList.of("test_fragment")).build();
assertThat(requiresFragments.getConfigurationFragmentPolicy()).isNotNull();
assertThat(requiresFragments.getConfigurationFragmentPolicy().isLegalConfigurationFragment(TestFragment.class, ConfigurationTransition.HOST)).isTrue();
}
use of com.google.devtools.build.lib.packages.AspectDefinition in project bazel by bazelbuild.
the class AspectDefinitionTest method testRequireProvider_AddsToSetOfRequiredProvidersAndNames.
@Test
public void testRequireProvider_AddsToSetOfRequiredProvidersAndNames() throws Exception {
AspectDefinition requiresProviders = new AspectDefinition.Builder(TEST_ASPECT_CLASS).requireProviders(String.class, Integer.class).build();
AdvertisedProviderSet expectedOkSet = AdvertisedProviderSet.builder().addNative(String.class).addNative(Integer.class).addNative(Boolean.class).build();
assertThat(requiresProviders.getRequiredProviders().isSatisfiedBy(expectedOkSet)).isTrue();
AdvertisedProviderSet expectedFailSet = AdvertisedProviderSet.builder().addNative(String.class).build();
assertThat(requiresProviders.getRequiredProviders().isSatisfiedBy(expectedFailSet)).isFalse();
assertThat(requiresProviders.getRequiredProviders().isSatisfiedBy(AdvertisedProviderSet.ANY)).isTrue();
assertThat(requiresProviders.getRequiredProviders().isSatisfiedBy(AdvertisedProviderSet.EMPTY)).isFalse();
}
use of com.google.devtools.build.lib.packages.AspectDefinition in project bazel by bazelbuild.
the class AspectDefinitionTest method testRequireAspectClass_DefaultAcceptsNothing.
@Test
public void testRequireAspectClass_DefaultAcceptsNothing() {
AspectDefinition noAspects = new AspectDefinition.Builder(TEST_ASPECT_CLASS).build();
AdvertisedProviderSet expectedFailSet = AdvertisedProviderSet.builder().addNative(Float.class).build();
assertThat(noAspects.getRequiredProvidersForAspects().isSatisfiedBy(AdvertisedProviderSet.ANY)).isFalse();
assertThat(noAspects.getRequiredProvidersForAspects().isSatisfiedBy(AdvertisedProviderSet.EMPTY)).isFalse();
assertThat(noAspects.getRequiredProvidersForAspects().isSatisfiedBy(expectedFailSet)).isFalse();
}
use of com.google.devtools.build.lib.packages.AspectDefinition in project bazel by bazelbuild.
the class AspectDefinitionTest method testAttributeAspect_AllAttributes.
@Test
public void testAttributeAspect_AllAttributes() throws Exception {
AspectDefinition withAspects = new AspectDefinition.Builder(TEST_ASPECT_CLASS).propagateAlongAllAttributes().build();
assertThat(withAspects.propagateAlong(createLabelListAttribute("srcs"))).isTrue();
assertThat(withAspects.propagateAlong(createLabelListAttribute("deps"))).isTrue();
}
Aggregations