Search in sources :

Example 86 with ProjectView

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

Example 87 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.

the class BlazeResolveConfigurationEquivalenceTest method testIncludes.

@Test
public void testIncludes() {
    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(), includes("foo/same"))).addTarget(createCcTarget("//foo/bar:two", Kind.CC_BINARY, sources("foo/bar/two.cc"), defines(), includes("foo/same"))).addTarget(createCcTarget("//foo/bar:three", Kind.CC_BINARY, sources("foo/bar/three.cc"), defines(), includes("foo/different"))).build();
    VirtualFile includeSame = createVirtualFile("/root/foo/same");
    VirtualFile includeDifferent = createVirtualFile("/root/foo/different");
    List<BlazeResolveConfiguration> configurations = resolve(projectView, targetMap);
    assertThat(configurations).hasSize(2);
    assertThat(getHeaders(get(configurations, "//foo/bar:one and 1 other target(s)"), OCLanguageKind.CPP)).containsExactly(header(includeSame));
    assertThat(getHeaders(get(configurations, "//foo/bar:three"), OCLanguageKind.CPP)).containsExactly(header(includeDifferent));
    for (BlazeResolveConfiguration configuration : configurations) {
        assertThat(configuration.getProjectHeadersRoots().getRoots()).isEmpty();
        assertThat(configuration.getCompilerMacros()).isEqualTo(macros());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) StubVirtualFile(com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile) 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