use of com.google.devtools.build.lib.analysis.ViewCreationFailedException in project bazel by bazelbuild.
the class SkylarkAspectsTest method duplicateOutputGroupsFromTwoAspects.
@Test
public void duplicateOutputGroupsFromTwoAspects() throws Exception {
scratch.file("test/aspect.bzl", "def _a1_impl(target, ctx):", " f = ctx.new_file(target.label.name + '_a1.txt')", " ctx.file_action(f, 'f')", " return struct(output_groups = { 'a1_group' : depset([f]) })", "", "a1 = aspect(implementation=_a1_impl, attr_aspects = ['dep'])", "def _rule_impl(ctx):", " if not ctx.attr.dep:", " return struct()", " og = {k:ctx.attr.dep.output_groups[k] for k in ctx.attr.dep.output_groups}", " return struct(output_groups = og)", "my_rule1 = rule(_rule_impl, attrs = { 'dep' : attr.label(aspects = [a1]) })", "def _a2_impl(target, ctx):", " g = ctx.new_file(target.label.name + '_a2.txt')", " ctx.file_action(g, 'f')", " return struct(output_groups = { 'a1_group' : depset([g]) })", "", "a2 = aspect(implementation=_a2_impl, attr_aspects = ['dep'])", "my_rule2 = rule(_rule_impl, attrs = { 'dep' : attr.label(aspects = [a2]) })");
scratch.file("test/BUILD", "load(':aspect.bzl', 'my_rule1', 'my_rule2')", "my_rule1(name = 'base')", "my_rule1(name = 'xxx', dep = ':base')", "my_rule2(name = 'yyy', dep = ':xxx')");
reporter.removeHandler(failFastHandler);
try {
AnalysisResult analysisResult = update("//test:yyy");
assertThat(analysisResult.hasError()).isTrue();
assertThat(keepGoing()).isTrue();
} catch (ViewCreationFailedException e) {
// expected.
}
assertContainsEvent("ERROR /workspace/test/BUILD:3:1: Output group a1_group provided twice");
}
Aggregations