use of com.google.devtools.build.lib.analysis.AspectCollection.AspectCycleOnPathException in project bazel by bazelbuild.
the class AspectCollectionTest method duplicateAspect4.
/**
* a2 wants a1, a3 wants a2, a1 wants a2. the path is [a2, a1, a2, a3], so a2 occurs twice.
* First occurrence of a2 does not see a1, but the second does => error.
* a1 disappears.
*/
@Test
public void duplicateAspect4() throws Exception {
Aspect a1 = createAspect("a1", "a2");
Aspect a2 = createAspect("a2", "a1");
Aspect a3 = createAspect("a3", "a2");
try {
AspectCollection.create(ImmutableList.of(a2, a1, a2, a3), ImmutableSet.of(a3.getDescriptor()));
Assert.fail();
} catch (AspectCycleOnPathException e) {
assertThat(e.getAspect()).isEqualTo(a2.getDescriptor());
assertThat(e.getPreviousAspect()).isEqualTo(a1.getDescriptor());
}
}
use of com.google.devtools.build.lib.analysis.AspectCollection.AspectCycleOnPathException in project bazel by bazelbuild.
the class AspectCollectionTest method duplicateAspect3.
/**
* a2 wants a1, a3 wants a1 and a2, a1 wants a2. the path is [a2, a1, a2, a3], so a2 occurs twice.
* First occurrence of a2 does not see a1, but the second does => error.
*/
@Test
public void duplicateAspect3() throws Exception {
Aspect a1 = createAspect("a1", "a2");
Aspect a2 = createAspect("a2", "a1");
Aspect a3 = createAspect("a3", "a1", "a2");
try {
AspectCollection.create(ImmutableList.of(a2, a1, a2, a3), ImmutableSet.of(a3.getDescriptor()));
Assert.fail();
} catch (AspectCycleOnPathException e) {
assertThat(e.getAspect()).isEqualTo(a2.getDescriptor());
assertThat(e.getPreviousAspect()).isEqualTo(a1.getDescriptor());
}
}
use of com.google.devtools.build.lib.analysis.AspectCollection.AspectCycleOnPathException in project bazel by bazelbuild.
the class DependencyResolver method requiredAspects.
private AspectCollection requiredAspects(Iterable<Aspect> aspectPath, AttributeAndOwner attributeAndOwner, final Target target, Rule originalRule) throws InconsistentAspectOrderException {
if (!(target instanceof Rule)) {
return AspectCollection.EMPTY;
}
if (attributeAndOwner.ownerAspect != null) {
// Do not propagate aspects along aspect attributes.
return AspectCollection.EMPTY;
}
ImmutableList.Builder<Aspect> filteredAspectPath = ImmutableList.builder();
ImmutableSet.Builder<AspectDescriptor> visibleAspects = ImmutableSet.builder();
Attribute attribute = attributeAndOwner.attribute;
collectOriginatingAspects(originalRule, attribute, (Rule) target, filteredAspectPath, visibleAspects);
collectPropagatingAspects(aspectPath, attribute, (Rule) target, filteredAspectPath, visibleAspects);
try {
return AspectCollection.create(filteredAspectPath.build(), visibleAspects.build());
} catch (AspectCycleOnPathException e) {
throw new InconsistentAspectOrderException(originalRule, attribute, target, e);
}
}
use of com.google.devtools.build.lib.analysis.AspectCollection.AspectCycleOnPathException in project bazel by bazelbuild.
the class AspectCollectionTest method duplicateAspect.
/**
* a2 wants a1, a3 wants a1 and a2, the path is [a2, a1, a2, a3], so a2 occurs twice.
*
* First occurrence of a2 would not see a1, but the second would: that is an error.
*/
@Test
public void duplicateAspect() throws Exception {
Aspect a1 = createAspect("a1");
Aspect a2 = createAspect("a2", "a1");
Aspect a3 = createAspect("a3", "a2", "a1");
try {
AspectCollection.create(ImmutableList.of(a2, a1, a2, a3), ImmutableSet.of(a3.getDescriptor()));
Assert.fail();
} catch (AspectCycleOnPathException e) {
assertThat(e.getAspect()).isEqualTo(a2.getDescriptor());
assertThat(e.getPreviousAspect()).isEqualTo(a1.getDescriptor());
}
}
use of com.google.devtools.build.lib.analysis.AspectCollection.AspectCycleOnPathException in project bazel by bazelbuild.
the class AspectCollectionTest method duplicateAspect2.
/**
* a2 wants a1, a3 wants a2, the path is [a2, a1, a2, a3], so a2 occurs twice.
*
* First occurrence of a2 would not see a1, but the second would: that is an error.
*/
@Test
public void duplicateAspect2() throws Exception {
Aspect a1 = createAspect("a1");
Aspect a2 = createAspect("a2", "a1");
Aspect a3 = createAspect("a3", "a2");
try {
AspectCollection.create(ImmutableList.of(a2, a1, a2, a3), ImmutableSet.of(a3.getDescriptor()));
Assert.fail();
} catch (AspectCycleOnPathException e) {
assertThat(e.getAspect()).isEqualTo(a2.getDescriptor());
assertThat(e.getPreviousAspect()).isEqualTo(a1.getDescriptor());
}
}
Aggregations