Search in sources :

Example 6 with AspectDefinition

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();
}
Also used : AspectDefinition(com.google.devtools.build.lib.packages.AspectDefinition) Test(org.junit.Test)

Example 7 with AspectDefinition

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();
}
Also used : AspectDefinition(com.google.devtools.build.lib.packages.AspectDefinition) Test(org.junit.Test)

Example 8 with AspectDefinition

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();
}
Also used : AdvertisedProviderSet(com.google.devtools.build.lib.packages.AdvertisedProviderSet) AspectDefinition(com.google.devtools.build.lib.packages.AspectDefinition) Test(org.junit.Test)

Example 9 with AspectDefinition

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();
}
Also used : AdvertisedProviderSet(com.google.devtools.build.lib.packages.AdvertisedProviderSet) AspectDefinition(com.google.devtools.build.lib.packages.AspectDefinition) Test(org.junit.Test)

Example 10 with AspectDefinition

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();
}
Also used : AspectDefinition(com.google.devtools.build.lib.packages.AspectDefinition) Test(org.junit.Test)

Aggregations

AspectDefinition (com.google.devtools.build.lib.packages.AspectDefinition)15 Test (org.junit.Test)14 AdvertisedProviderSet (com.google.devtools.build.lib.packages.AdvertisedProviderSet)3 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 AnalysisResult (com.google.devtools.build.lib.analysis.BuildView.AnalysisResult)1 AspectParameters (com.google.devtools.build.lib.packages.AspectParameters)1 Attribute (com.google.devtools.build.lib.packages.Attribute)1 LateBoundLabel (com.google.devtools.build.lib.packages.Attribute.LateBoundLabel)1 AttributeMap (com.google.devtools.build.lib.packages.AttributeMap)1 NativeAspectClass (com.google.devtools.build.lib.packages.NativeAspectClass)1 Rule (com.google.devtools.build.lib.packages.Rule)1 AspectValue (com.google.devtools.build.lib.skyframe.AspectValue)1