Search in sources :

Example 66 with TargetMap

use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.

the class BlazeConfigurationResolverTest method completelyDifferentTargetsSameProjectView_testIncrementalUpdateNoReuse.

@Test
public void completelyDifferentTargetsSameProjectView_testIncrementalUpdateNoReuse() {
    ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:*"));
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc")))).build();
    ImmutableList<BlazeResolveConfiguration> noReusedConfigurations = ImmutableList.of();
    assertThatResolving(projectView, targetMap).reusedConfigurations(noReusedConfigurations, "//foo/bar:binary");
    TargetMap targetMap2 = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/bar/library.cc")), ImmutableList.of("OTHER=1"))).build();
    assertThatResolving(projectView, targetMap2).reusedConfigurations(noReusedConfigurations, "//foo/bar:library");
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 67 with TargetMap

use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.

the class BlazeConfigurationResolverTest method completelyDifferentTargetsDifferentProjectView_testIncrementalUpdateNoReuse.

@Test
public void completelyDifferentTargetsDifferentProjectView_testIncrementalUpdateNoReuse() {
    ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:binary"));
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc")))).build();
    ImmutableList<BlazeResolveConfiguration> noReusedConfigurations = ImmutableList.of();
    assertThatResolving(projectView, targetMap).reusedConfigurations(noReusedConfigurations, "//foo/bar:binary");
    ProjectView projectView2 = projectView(directories("foo/zoo"), targets("//foo/zoo:library"));
    TargetMap targetMap2 = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/zoo:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/zoo/library.cc")), ImmutableList.of("OTHER=1"))).build();
    assertThatResolving(projectView2, targetMap2).reusedConfigurations(noReusedConfigurations, "//foo/zoo:library");
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 68 with TargetMap

use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.

the class BlazeResolveConfigurationEquivalenceTest method changeDefinesWithSameStructure_testIncrementalUpdate.

@Test
public void changeDefinesWithSameStructure_testIncrementalUpdate() {
    ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:...:all"));
    TargetMap targetMap = incrementalUpdateTestCaseInitialTargetMap();
    List<BlazeResolveConfiguration> configurations = resolve(projectView, targetMap);
    assertThat(configurations).hasSize(2);
    assertThat(get(configurations, "//foo/bar:a and 2 other target(s)")).isNotNull();
    assertThat(get(configurations, "//foo/bar:d")).isNotNull();
    targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:a", Kind.CC_BINARY, sources("foo/bar/a.cc"), defines("CHANGED=1"), includes())).addTarget(createCcTarget("//foo/bar:b", Kind.CC_BINARY, sources("foo/bar/b.cc"), defines("CHANGED=1"), includes())).addTarget(createCcTarget("//foo/bar:c", Kind.CC_BINARY, sources("foo/bar/c.cc"), defines("CHANGED=1"), includes())).addTarget(createCcTarget("//foo/bar:d", Kind.CC_BINARY, sources("foo/bar/d.cc"), defines("DIFFERENT=1"), includes())).build();
    List<BlazeResolveConfiguration> newConfigurations = resolve(projectView, targetMap);
    assertThat(newConfigurations).hasSize(2);
    assertReusedConfigs(configurations, newConfigurations, new ReusedConfigurationExpectations(ImmutableList.of("//foo/bar:d"), ImmutableList.of("//foo/bar:a and 2 other target(s)")));
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 69 with TargetMap

use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.

the class BlazeResolveConfigurationEquivalenceTest method testDefines.

@Test
public void testDefines() {
    ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:one", "//foo/bar:two", "//foo/bar:three"));
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:one", Kind.CC_BINARY, sources("foo/bar/one.cc"), defines("SAME=1"), includes())).addTarget(createCcTarget("//foo/bar:two", Kind.CC_BINARY, sources("foo/bar/two.cc"), defines("SAME=1"), includes())).addTarget(createCcTarget("//foo/bar:three", Kind.CC_BINARY, sources("foo/bar/three.cc"), defines("DIFFERENT=1"), includes())).build();
    List<BlazeResolveConfiguration> configurations = resolve(projectView, targetMap);
    assertThat(configurations).hasSize(2);
    assertThat(get(configurations, "//foo/bar:one and 1 other target(s)").getCompilerMacros()).isEqualTo(macros("SAME=1"));
    assertThat(get(configurations, "//foo/bar:three").getCompilerMacros()).isEqualTo(macros("DIFFERENT=1"));
    for (BlazeResolveConfiguration configuration : configurations) {
        assertThat(configuration.getProjectHeadersRoots().getRoots()).isEmpty();
        assertThat(getHeaders(configuration, OCLanguageKind.CPP)).isEmpty();
    }
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 70 with TargetMap

use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.

the class BlazeResolveConfigurationEquivalenceTest method changeDefinesMakeAllSame_testIncrementalUpdate.

@Test
public void changeDefinesMakeAllSame_testIncrementalUpdate() {
    ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:...:all"));
    TargetMap targetMap = incrementalUpdateTestCaseInitialTargetMap();
    List<BlazeResolveConfiguration> configurations = resolve(projectView, targetMap);
    assertThat(configurations).hasSize(2);
    assertThat(get(configurations, "//foo/bar:a and 2 other target(s)")).isNotNull();
    assertThat(get(configurations, "//foo/bar:d")).isNotNull();
    targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:a", Kind.CC_BINARY, sources("foo/bar/a.cc"), defines("SAME=1"), includes())).addTarget(createCcTarget("//foo/bar:b", Kind.CC_BINARY, sources("foo/bar/b.cc"), defines("SAME=1"), includes())).addTarget(createCcTarget("//foo/bar:c", Kind.CC_BINARY, sources("foo/bar/c.cc"), defines("SAME=1"), includes())).addTarget(createCcTarget("//foo/bar:d", Kind.CC_BINARY, sources("foo/bar/d.cc"), defines("SAME=1"), includes())).build();
    List<BlazeResolveConfiguration> newConfigurations = resolve(projectView, targetMap);
    assertThat(newConfigurations).hasSize(1);
    // What used to be "//foo/bar:a and 2 other target(s)" will be renamed to
    // "//foo/bar:a and 3 other target(s)" and reused.
    assertReusedConfigs(configurations, newConfigurations, new ReusedConfigurationExpectations(ImmutableList.of("//foo/bar:a and 3 other target(s)"), ImmutableList.of()));
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Aggregations

TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)77 Test (org.junit.Test)56 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)33 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)27 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)26 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)17 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)16 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)15 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)12 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)11 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)11 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)10 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)10 BlazeScalaImportResult (com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult)10 File (java.io.File)10 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)9 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)9 ImmutableList (com.google.common.collect.ImmutableList)8 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)8 ImmutableSet (com.google.common.collect.ImmutableSet)7