Search in sources :

Example 81 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView 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 82 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView 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 83 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView 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 84 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView 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 85 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView 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

ProjectView (com.google.idea.blaze.base.projectview.ProjectView)87 Test (org.junit.Test)81 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)55 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)45 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)40 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)33 BlazeAndroidImportResult (com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult)13 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)12 File (java.io.File)12 BlazeScalaImportResult (com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult)9 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)8 AndroidAarIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo)7 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)6 WorkingSet (com.google.idea.blaze.base.sync.workspace.WorkingSet)5 JavaWorkingSet (com.google.idea.blaze.java.sync.workingset.JavaWorkingSet)5 ImmutableList (com.google.common.collect.ImmutableList)4 GenfilesPath (com.google.idea.blaze.android.projectview.GenfilesPath)4 BlazeAndroidLibrarySource (com.google.idea.blaze.android.sync.BlazeAndroidLibrarySource)4 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 DirectorySection (com.google.idea.blaze.base.projectview.section.sections.DirectorySection)4