diff options
Diffstat (limited to 'src/test/java')
3 files changed, 33 insertions, 30 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AspectDefinitionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AspectDefinitionTest.java index 667af95af3..eb6b8f8070 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/AspectDefinitionTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/AspectDefinitionTest.java @@ -40,6 +40,7 @@ import org.junit.runners.JUnit4; */ @RunWith(JUnit4.class) public class AspectDefinitionTest { + /** * A dummy aspect factory. Is there to demonstrate how to define aspects and so that we can test * {@code attributeAspect}. @@ -77,7 +78,7 @@ public class AspectDefinitionTest { return Label.parseAbsoluteUnchecked("//run:away"); } }; - AspectDefinition simple = new AspectDefinition.Builder("simple") + AspectDefinition simple = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .add(implicit) .add(attr(":latebound", BuildType.LABEL).value(latebound)) .build(); @@ -90,7 +91,7 @@ public class AspectDefinitionTest { @Test public void testAspectWithDuplicateAttribute_FailsToAdd() throws Exception { try { - new AspectDefinition.Builder("clash") + new AspectDefinition.Builder(TEST_ASPECT_CLASS) .add(attr("$runtime", BuildType.LABEL).value(Label.parseAbsoluteUnchecked("//run:time"))) .add(attr("$runtime", BuildType.LABEL).value(Label.parseAbsoluteUnchecked("//oops"))); fail(); // expected IllegalArgumentException @@ -102,7 +103,7 @@ public class AspectDefinitionTest { @Test public void testAspectWithUserVisibleAttribute_FailsToAdd() throws Exception { try { - new AspectDefinition.Builder("user_visible_attribute") + new AspectDefinition.Builder(TEST_ASPECT_CLASS) .add( attr("invalid", BuildType.LABEL) .value(Label.parseAbsoluteUnchecked("//run:time")) @@ -116,7 +117,7 @@ public class AspectDefinitionTest { @Test public void testAttributeAspect_WrapsAndAddsToMap() throws Exception { - AspectDefinition withAspects = new AspectDefinition.Builder("attribute_aspect") + AspectDefinition withAspects = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .attributeAspect("srcs", TEST_ASPECT_CLASS) .attributeAspect("deps", TEST_ASPECT_CLASS) .build(); @@ -129,7 +130,7 @@ public class AspectDefinitionTest { @Test public void testAttributeAspect_AllAttributes() throws Exception { - AspectDefinition withAspects = new AspectDefinition.Builder("attribute_aspect") + AspectDefinition withAspects = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .allAttributesAspect(TEST_ASPECT_CLASS) .build(); @@ -148,7 +149,7 @@ public class AspectDefinitionTest { @Test public void testRequireProvider_AddsToSetOfRequiredProvidersAndNames() throws Exception { - AspectDefinition requiresProviders = new AspectDefinition.Builder("required_providers") + AspectDefinition requiresProviders = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .requireProvider(String.class) .requireProvider(Integer.class) .build(); @@ -160,14 +161,14 @@ public class AspectDefinitionTest { @Test public void testNoConfigurationFragmentPolicySetup_HasNonNullPolicy() throws Exception { - AspectDefinition noPolicy = new AspectDefinition.Builder("no_policy") + AspectDefinition noPolicy = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .build(); assertThat(noPolicy.getConfigurationFragmentPolicy()).isNotNull(); } @Test public void testMissingFragmentPolicy_PropagatedToConfigurationFragmentPolicy() throws Exception { - AspectDefinition missingFragments = new AspectDefinition.Builder("missing_fragments") + AspectDefinition missingFragments = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .setMissingFragmentPolicy(MissingFragmentPolicy.IGNORE) .build(); assertThat(missingFragments.getConfigurationFragmentPolicy()).isNotNull(); @@ -178,7 +179,7 @@ public class AspectDefinitionTest { @Test public void testRequiresConfigurationFragments_PropagatedToConfigurationFragmentPolicy() throws Exception { - AspectDefinition requiresFragments = new AspectDefinition.Builder("requires_fragments") + AspectDefinition requiresFragments = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .requiresConfigurationFragments(Integer.class, String.class) .build(); assertThat(requiresFragments.getConfigurationFragmentPolicy()).isNotNull(); @@ -190,7 +191,7 @@ public class AspectDefinitionTest { @Test public void testRequiresHostConfigurationFragments_PropagatedToConfigurationFragmentPolicy() throws Exception { - AspectDefinition requiresFragments = new AspectDefinition.Builder("requires_fragments") + AspectDefinition requiresFragments = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .requiresHostConfigurationFragments(Integer.class, String.class) .build(); assertThat(requiresFragments.getConfigurationFragmentPolicy()).isNotNull(); @@ -202,7 +203,7 @@ public class AspectDefinitionTest { @Test public void testRequiresConfigurationFragmentNames_PropagatedToConfigurationFragmentPolicy() throws Exception { - AspectDefinition requiresFragments = new AspectDefinition.Builder("requires_fragments") + AspectDefinition requiresFragments = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .requiresConfigurationFragmentsBySkylarkModuleName(ImmutableList.of("test_fragment")) .build(); assertThat(requiresFragments.getConfigurationFragmentPolicy()).isNotNull(); @@ -215,7 +216,7 @@ public class AspectDefinitionTest { @Test public void testRequiresHostConfigurationFragmentNames_PropagatedToConfigurationFragmentPolicy() throws Exception { - AspectDefinition requiresFragments = new AspectDefinition.Builder("requires_fragments") + AspectDefinition requiresFragments = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .requiresHostConfigurationFragmentsBySkylarkModuleName(ImmutableList.of("test_fragment")) .build(); assertThat(requiresFragments.getConfigurationFragmentPolicy()).isNotNull(); @@ -227,7 +228,7 @@ public class AspectDefinitionTest { @Test public void testEmptySkylarkConfigurationFragmentPolicySetup_HasNonNullPolicy() throws Exception { - AspectDefinition noPolicy = new AspectDefinition.Builder("no_policy") + AspectDefinition noPolicy = new AspectDefinition.Builder(TEST_ASPECT_CLASS) .requiresConfigurationFragmentsBySkylarkModuleName(ImmutableList.<String>of()) .requiresHostConfigurationFragmentsBySkylarkModuleName(ImmutableList.<String>of()) .build(); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java index af00a7ee76..37abaafb46 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java @@ -321,7 +321,7 @@ public class AspectTest extends AnalysisTestCase { implements ConfiguredAspectFactory { @Override public AspectDefinition getDefinition(AspectParameters params) { - return new AspectDefinition.Builder("testaspect") + return new AspectDefinition.Builder(this) .add(attr(":late", LABEL).value(EMPTY_LATE_BOUND_LABEL)).build(); } @@ -330,7 +330,7 @@ public class AspectTest extends AnalysisTestCase { ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) throws InterruptedException { Object lateBoundPrereq = ruleContext.getPrerequisite(":late", TARGET); - return new ConfiguredAspect.Builder("testaspect", ruleContext) + return new ConfiguredAspect.Builder(this, parameters, ruleContext) .addProvider( AspectInfo.class, new AspectInfo( @@ -385,15 +385,17 @@ public class AspectTest extends AnalysisTestCase { implements ConfiguredAspectFactory { @Override public AspectDefinition getDefinition(AspectParameters params) { - return new AspectDefinition.Builder("testaspect").build(); + return new AspectDefinition.Builder(this).build(); } + + @Override public ConfiguredAspect create( ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) throws InterruptedException { ruleContext.registerAction(new NullAction(ruleContext.createOutputArtifact())); - return new ConfiguredAspect.Builder("testaspect", ruleContext).build(); + return new ConfiguredAspect.Builder(this, parameters, ruleContext).build(); } } private static final AspectThatRegistersAction ASPECT_THAT_REGISTERS_ACTION = diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java b/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java index f6f693e0e3..55b0fe84d8 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java @@ -170,7 +170,7 @@ public class TestAspects { String information = parameters.isEmpty() ? "" : " data " + Iterables.getFirst(parameters.getAttribute("baz"), null); - return new ConfiguredAspect.Builder(getClass().getName(), ruleContext) + return new ConfiguredAspect.Builder(this, parameters, ruleContext) .addProvider( new AspectInfo( collectAspectData("aspect " + ruleContext.getLabel() + information, ruleContext))) @@ -180,7 +180,7 @@ public class TestAspects { public static final SimpleAspect SIMPLE_ASPECT = new SimpleAspect(); private static final AspectDefinition SIMPLE_ASPECT_DEFINITION = - new AspectDefinition.Builder("simple").build(); + new AspectDefinition.Builder(SIMPLE_ASPECT).build(); /** * A very simple aspect. @@ -194,14 +194,14 @@ public class TestAspects { public static final ExtraAttributeAspect EXTRA_ATTRIBUTE_ASPECT = new ExtraAttributeAspect(); private static final AspectDefinition EXTRA_ATTRIBUTE_ASPECT_DEFINITION = - new AspectDefinition.Builder("extra_attribute") + new AspectDefinition.Builder(EXTRA_ATTRIBUTE_ASPECT) .add(attr("$dep", LABEL).value(Label.parseAbsoluteUnchecked("//extra:extra"))) .build(); private static final ExtraAttributeAspectRequiringProvider EXTRA_ATTRIBUTE_ASPECT_REQUIRING_PROVIDER = new ExtraAttributeAspectRequiringProvider(); private static final AspectDefinition EXTRA_ATTRIBUTE_ASPECT_REQUIRING_PROVIDER_DEFINITION = - new AspectDefinition.Builder("extra_attribute_with_provider") + new AspectDefinition.Builder(EXTRA_ATTRIBUTE_ASPECT_REQUIRING_PROVIDER) .add(attr("$dep", LABEL).value(Label.parseAbsoluteUnchecked("//extra:extra"))) .requireProvider(RequiredProvider.class) .build(); @@ -218,7 +218,7 @@ public class TestAspects { public static final AttributeAspect ATTRIBUTE_ASPECT = new AttributeAspect(); private static final AspectDefinition ATTRIBUTE_ASPECT_DEFINITION = - new AspectDefinition.Builder("attribute") + new AspectDefinition.Builder(ATTRIBUTE_ASPECT) .attributeAspect("foo", ATTRIBUTE_ASPECT) .build(); @@ -234,7 +234,7 @@ public class TestAspects { } public static final NativeAspectClass ALL_ATTRIBUTES_ASPECT = new AllAttributesAspect(); private static final AspectDefinition ALL_ATTRIBUTES_ASPECT_DEFINITION = - new AspectDefinition.Builder("all_attributes_aspect") + new AspectDefinition.Builder(ALL_ATTRIBUTES_ASPECT) .allAttributesAspect(ALL_ATTRIBUTES_ASPECT) .build(); @@ -250,7 +250,7 @@ public class TestAspects { public static final NativeAspectClass ALL_ATTRIBUTES_WITH_TOOL_ASPECT = new AllAttributesWithToolAspect(); private static final AspectDefinition ALL_ATTRIBUTES_WITH_TOOL_ASPECT_DEFINITION = - new AspectDefinition.Builder("all_attributes_with_tool_aspect") + new AspectDefinition.Builder(ALL_ATTRIBUTES_WITH_TOOL_ASPECT) .allAttributesAspect(ALL_ATTRIBUTES_WITH_TOOL_ASPECT) .add( attr("$tool", BuildType.LABEL) @@ -294,7 +294,7 @@ public class TestAspects { @Override public AspectDefinition getDefinition(AspectParameters aspectParameters) { AspectDefinition.Builder builder = - new AspectDefinition.Builder("parametrized_definition_aspect") + new AspectDefinition.Builder(PARAMETRIZED_DEFINITION_ASPECT) .attributeAspect("foo", this); ImmutableCollection<String> baz = aspectParameters.getAttribute("baz"); if (baz != null) { @@ -323,7 +323,7 @@ public class TestAspects { information.append(dep.getLabel()); } information.append("]"); - return new ConfiguredAspect.Builder(getClass().getName(), ruleContext) + return new ConfiguredAspect.Builder(this, parameters, ruleContext) .addProvider(new AspectInfo(collectAspectData(information.toString(), ruleContext))) .build(); } @@ -335,7 +335,7 @@ public class TestAspects { private static final AspectRequiringProvider ASPECT_REQUIRING_PROVIDER = new AspectRequiringProvider(); private static final AspectDefinition ASPECT_REQUIRING_PROVIDER_DEFINITION = - new AspectDefinition.Builder("requiring_provider") + new AspectDefinition.Builder(ASPECT_REQUIRING_PROVIDER) .requireProvider(RequiredProvider.class) .build(); @@ -349,7 +349,7 @@ public class TestAspects { public ConfiguredAspect create( ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) { ruleContext.ruleWarning("Aspect warning on " + base.getTarget().getLabel()); - return new ConfiguredAspect.Builder("warning", ruleContext).build(); + return new ConfiguredAspect.Builder(this, parameters, ruleContext).build(); } @Override @@ -360,7 +360,7 @@ public class TestAspects { public static final WarningAspect WARNING_ASPECT = new WarningAspect(); private static final AspectDefinition WARNING_ASPECT_DEFINITION = - new AspectDefinition.Builder("warning") + new AspectDefinition.Builder(WARNING_ASPECT) .attributeAspect("bar", WARNING_ASPECT) .build(); @@ -385,7 +385,7 @@ public class TestAspects { public static final ErrorAspect ERROR_ASPECT = new ErrorAspect(); private static final AspectDefinition ERROR_ASPECT_DEFINITION = - new AspectDefinition.Builder("error") + new AspectDefinition.Builder(ERROR_ASPECT) .attributeAspect("bar", ERROR_ASPECT) .build(); |