use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class ReverseDependencyMapTest method testThreeLevelGraph.
@Test
public void testThreeLevelGraph() {
TargetMapBuilder builder = TargetMapBuilder.builder();
TargetMap targetMap = builder.addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//l:l1").setKind("java_library").addDependency("//l:l3")).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//l:l2").addDependency("//l:l3").setKind("java_library")).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//l:l3").setKind("java_library")).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//l:l4").addDependency("//l:l3").setKind("java_library")).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//l:l5").addDependency("//l:l4").setKind("java_library")).build();
ImmutableMultimap<TargetKey, TargetKey> reverseDependencies = ReverseDependencyMap.createRdepsMap(targetMap);
assertThat(reverseDependencies).containsEntry(TargetKey.forPlainTarget(Label.create("//l:l3")), TargetKey.forPlainTarget(Label.create("//l:l1")));
assertThat(reverseDependencies).containsEntry(TargetKey.forPlainTarget(Label.create("//l:l3")), TargetKey.forPlainTarget(Label.create("//l:l2")));
assertThat(reverseDependencies).containsEntry(TargetKey.forPlainTarget(Label.create("//l:l3")), TargetKey.forPlainTarget(Label.create("//l:l4")));
assertThat(reverseDependencies).containsEntry(TargetKey.forPlainTarget(Label.create("//l:l4")), TargetKey.forPlainTarget(Label.create("//l:l5")));
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method newTarget_testIncrementalUpdatePartlyReused.
@Test
public void newTarget_testIncrementalUpdatePartlyReused() {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:*"));
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc"))));
assertThatResolving(projectView, targetMapBuilder.build()).producesConfigurationsFor("//foo/bar:binary");
Collection<BlazeResolveConfiguration> initialConfigurations = resolverResult.getAllConfigurations();
targetMapBuilder.addTarget(createCcTarget("//foo/bar:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/bar/library.cc")), ImmutableList.of("OTHER=1")));
assertThatResolving(projectView, targetMapBuilder.build()).reusedConfigurations(initialConfigurations, "//foo/bar:library");
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method afterQueryingConfiguration_newTarget_testIncrementalUpdatePartlyReused.
@Test
public void afterQueryingConfiguration_newTarget_testIncrementalUpdatePartlyReused() {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:*"));
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc"))));
assertThatResolving(projectView, targetMapBuilder.build()).producesConfigurationsFor("//foo/bar:binary");
Collection<BlazeResolveConfiguration> initialConfigurations = resolverResult.getAllConfigurations();
// Make sure that if we *query* the configuration in some way, it doesn't affect its
// compatibility / reusability. There may be caches attached to the configuration and those
// should not be compared when checking equivalence.
OCResolveConfiguration firstConfiguration = initialConfigurations.iterator().next();
firstConfiguration.getLibraryHeadersRoots(new OCResolveRootAndConfiguration(firstConfiguration, OCLanguageKind.CPP));
targetMapBuilder.addTarget(createCcTarget("//foo/bar:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/bar/library.cc")), ImmutableList.of("OTHER=1")));
assertThatResolving(projectView, targetMapBuilder.build()).reusedConfigurations(initialConfigurations, "//foo/bar:library");
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeResolveConfigurationEquivalenceTest method do_changeDefines_testIncrementalUpdate.
private void do_changeDefines_testIncrementalUpdate(List<String> labelsToFlip, ReusedConfigurationExpectations expectation) {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:...:all"));
List<BlazeResolveConfiguration> configurations = resolve(projectView, incrementalUpdateTestCaseInitialTargetMap());
assertThat(configurations).hasSize(2);
assertThat(get(configurations, "//foo/bar:a and 2 other target(s)")).isNotNull();
assertThat(get(configurations, "//foo/bar:d")).isNotNull();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(createCcToolchain());
for (String target : ImmutableList.of("a", "b", "c")) {
if (labelsToFlip.contains(target)) {
targetMapBuilder.addTarget(createCcTarget(String.format("//foo/bar:%s", target), Kind.CC_BINARY, sources(String.format("foo/bar/%s.cc", target)), defines("DIFFERENT=1"), includes()));
} else {
targetMapBuilder.addTarget(createCcTarget(String.format("//foo/bar:%s", target), Kind.CC_BINARY, sources(String.format("foo/bar/%s.cc", target)), defines("SAME=1"), includes()));
}
}
targetMapBuilder.addTarget(createCcTarget("//foo/bar:d", Kind.CC_BINARY, sources("foo/bar/d.cc"), defines("DIFFERENT=1"), includes()));
List<BlazeResolveConfiguration> newConfigurations = resolve(projectView, targetMapBuilder.build());
assertReusedConfigs(configurations, newConfigurations, expectation);
}
Aggregations