use of com.google.devtools.build.lib.packages.Aspect in project bazel by bazelbuild.
the class AspectCollectionTest method linearAspectPath1.
/**
* a3 wants a1 and a2, a1 and a2 want no one, path is a1, a2, a3.
*/
@Test
public void linearAspectPath1() throws Exception {
Aspect a1 = createAspect("a1");
Aspect a2 = createAspect("a2");
Aspect a3 = createAspect("a3", "a1", "a2");
AspectCollection collection = AspectCollection.create(ImmutableList.of(a1, a2, a3), ImmutableSet.of(a3.getDescriptor()));
validateAspectCollection(collection, ImmutableList.of(a1, a2, a3), ImmutableList.of(a3), expectDeps(a3, a1, a2), expectDeps(a1), expectDeps(a2));
}
use of com.google.devtools.build.lib.packages.Aspect 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.packages.Aspect 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());
}
}
use of com.google.devtools.build.lib.packages.Aspect in project bazel by bazelbuild.
the class AspectCollectionTest method validateOrder.
/**
* a3 wants a1, a1 wants a2, path is a1, a2, a3, so a2 comes after a1.
*/
@Test
public void validateOrder() throws Exception {
Aspect a1 = createAspect("a1", "a2");
Aspect a2 = createAspect("a2");
Aspect a3 = createAspect("a3", "a1");
AspectCollection collection = AspectCollection.create(ImmutableList.of(a1, a2, a3), ImmutableSet.of(a3.getDescriptor()));
validateAspectCollection(collection, ImmutableList.of(a1, a3), ImmutableList.of(a3), expectDeps(a3, a1), expectDeps(a1));
}
use of com.google.devtools.build.lib.packages.Aspect in project bazel by bazelbuild.
the class AspectCollectionTest method validateAspectPaths.
private static void validateAspectPaths(AspectCollection collection, ImmutableList<Pair<Aspect, ImmutableList<Aspect>>> expectedList) {
HashMap<AspectDescriptor, AspectDeps> allPaths = new HashMap<>();
for (AspectDeps aspectPath : collection.getVisibleAspects()) {
collectAndValidateAspectDeps(aspectPath, allPaths);
}
HashSet<AspectDescriptor> expectedKeys = new HashSet<>();
for (Pair<Aspect, ImmutableList<Aspect>> expected : expectedList) {
assertThat(allPaths).containsKey(expected.first.getDescriptor());
AspectDeps aspectPath = allPaths.get(expected.first.getDescriptor());
assertThat(Iterables.transform(aspectPath.getDependentAspects(), ASPECT_PATH_TO_DESCRIPTOR)).containsExactlyElementsIn(Iterables.transform(expected.second, ASPECT_TO_DESCRIPTOR)).inOrder();
expectedKeys.add(expected.first.getDescriptor());
}
assertThat(allPaths.keySet()).containsExactlyElementsIn(expectedKeys);
}
Aggregations