Search in sources :

Example 46 with TargetMapBuilder

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")));
}
Also used : TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 47 with TargetMapBuilder

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");
}
Also used : TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Example 48 with TargetMapBuilder

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");
}
Also used : OCResolveConfiguration(com.jetbrains.cidr.lang.workspace.OCResolveConfiguration) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) OCResolveRootAndConfiguration(com.jetbrains.cidr.lang.workspace.OCResolveRootAndConfiguration) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Example 49 with TargetMapBuilder

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);
}
Also used : TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) ProjectView(com.google.idea.blaze.base.projectview.ProjectView)

Aggregations

TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)49 Test (org.junit.Test)48 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)44 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)40 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)33 BlazeAndroidImportResult (com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult)13 AndroidAarIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo)7 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)7 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)7 BlazeAndroidLibrarySource (com.google.idea.blaze.android.sync.BlazeAndroidLibrarySource)5 WorkingSet (com.google.idea.blaze.base.sync.workspace.WorkingSet)5 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)5 JavaWorkingSet (com.google.idea.blaze.java.sync.workingset.JavaWorkingSet)5 GenfilesPath (com.google.idea.blaze.android.projectview.GenfilesPath)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 BlazeResourceLibrary (com.google.idea.blaze.android.sync.model.BlazeResourceLibrary)3 BlazeTestCase (com.google.idea.blaze.base.BlazeTestCase)3 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)3 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)3