Search in sources :

Example 36 with ProjectView

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

the class BlazeConfigurationResolverTest method testComplexProject.

@Test
public void testComplexProject() {
    ProjectView projectView = projectView(directories("foo/bar", "foo/baz"), targets("//foo:test", "//foo/bar:binary", "//foo/baz:test"));
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo:test", Kind.CC_TEST, ImmutableList.of(src("foo/test.cc"))).addDependency("//foo:library").addDependency("//foo/bar:library").addDependency("//third_party:library")).addTarget(createCcTarget("//foo:library", Kind.CC_TEST, ImmutableList.of(src("foo/library.cc")))).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc")), ImmutableList.of("SOME_DEFINE=1")).addDependency("//foo/bar:library").addDependency("//foo/bar:empty").addDependency("//foo/bar:generated").addDependency("//foo/bar:mixed").addDependency("//third_party:library")).addTarget(createCcTarget("//foo/bar:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/bar/library.cc")), ImmutableList.of("SOME_DEFINE=2"))).addTarget(createCcTarget("//foo/bar:empty", Kind.CC_LIBRARY, ImmutableList.of())).addTarget(createCcTarget("//foo/bar:generated", Kind.CC_LIBRARY, ImmutableList.of(gen("foo/bar/generated.cc")))).addTarget(createCcTarget("//foo/bar:mixed", Kind.CC_LIBRARY, ImmutableList.of(src("foo/bar/mixed_src.cc"), gen("foo/bar/mixed_gen.cc")), ImmutableList.of("SOME_DEFINE=3"))).addTarget(createCcTarget("//foo/baz:test", Kind.CC_TEST, ImmutableList.of(src("foo/baz/test.cc")), ImmutableList.of("SOME_DEFINE=4")).addDependency("//foo/baz:binary").addDependency("//foo/baz:library").addDependency("//foo/qux:library")).addTarget(createCcTarget("//foo/baz:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/baz/binary.cc")), ImmutableList.of("SOME_DEFINE=5"))).addTarget(createCcTarget("//foo/baz:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/baz/library.cc")), ImmutableList.of("SOME_DEFINE=6"))).addTarget(createCcTarget("//foo/qux:library", Kind.CC_LIBRARY, ImmutableList.of(src("foo/qux/library.cc")))).addTarget(createCcTarget("//third_party:library", Kind.CC_LIBRARY, ImmutableList.of(src("third_party/library.cc")))).build();
    assertThatResolving(projectView, targetMap).producesConfigurationsFor("//foo/bar:binary", "//foo/bar:library", "//foo/bar:mixed", "//foo/baz:test", "//foo/baz:binary", "//foo/baz:library");
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 37 with ProjectView

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

the class BlazeResolveConfigurationEquivalenceTest method testEmptyConfigurations.

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

Example 38 with ProjectView

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

the class BlazeScalaWorkspaceImporterTest method testSingleScalaBinary.

@Test
public void testSingleScalaBinary() {
    ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example")))).build();
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setBuildFile(source("src/main/scala/apps/example/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).addSource(source("src/main/scala/apps/example/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar"))))).build();
    BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
    BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
    errorCollector.assertNoIssues();
    assertThat(javaImportResult.contentEntries).containsExactly(BlazeContentEntry.builder("/root/src/main/scala/apps/example").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/example").setPackagePrefix("apps.example").build()).build());
    assertThat(javaImportResult.libraries).isEmpty();
    assertThat(javaImportResult.javaSourceFiles).containsExactly(source("src/main/scala/apps/example/Main.scala"), source("src/main/scala/apps/example/subdir/SubdirHelper.scala"));
    assertThat(scalaImportResult.libraries).isEmpty();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) BlazeScalaImportResult(com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 39 with ProjectView

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

the class BlazeScalaWorkspaceImporterTest method testTwoScalaBinariesWithSharedLibrary.

@Test
public void testTwoScalaBinariesWithSharedLibrary() {
    ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example"))).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/other")))).build();
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setBuildFile(source("src/main/scala/apps/example/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).addSource(source("src/main/scala/apps/example/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar")))).addDependency("//src/main/scala/some/library:library")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/other:other").setBuildFile(source("src/main/scala/apps/other/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/other/Main.scala")).addSource(source("src/main/scala/apps/other/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/other/other.jar")).setClassJar(gen("src/main/scala/apps/other/other.jar")))).addDependency("//src/main/scala/some/library:library")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/some/library:library").setBuildFile(source("src/main/scala/some/library/BUILD")).setKind("scala_library").addSource(source("src/main/scala/some/library/Library.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/some/library/library_ijar.jar")).setClassJar(gen("src/main/scala/some/library/library.jar"))))).build();
    BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
    BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
    errorCollector.assertNoIssues();
    assertThat(javaImportResult.contentEntries).containsExactly(BlazeContentEntry.builder("/root/src/main/scala/apps/example").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/example").setPackagePrefix("apps.example").build()).build(), BlazeContentEntry.builder("/root/src/main/scala/apps/other").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/other").setPackagePrefix("apps.other").build()).build());
    // Direct library deps will be double counted.
    assertThat(javaImportResult.libraries).hasSize(1);
    assertThat(hasLibrary(javaImportResult.libraries, "library_ijar")).isTrue();
    assertThat(javaImportResult.javaSourceFiles).containsExactly(source("src/main/scala/apps/example/Main.scala"), source("src/main/scala/apps/example/subdir/SubdirHelper.scala"), source("src/main/scala/apps/other/Main.scala"), source("src/main/scala/apps/other/subdir/SubdirHelper.scala"));
    assertThat(scalaImportResult.libraries).hasSize(1);
    assertThat(hasLibrary(scalaImportResult.libraries, "library_ijar")).isTrue();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) BlazeScalaImportResult(com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 40 with ProjectView

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

the class BlazeScalaWorkspaceImporterTest method testEmptyProject.

@Test
public void testEmptyProject() {
    ProjectView projectView = ProjectView.builder().build();
    TargetMap targetMap = TargetMapBuilder.builder().build();
    BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
    BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
    errorCollector.assertNoIssues();
    assertThat(javaImportResult.libraries).isEmpty();
    assertThat(javaImportResult.contentEntries).isEmpty();
    assertThat(javaImportResult.javaSourceFiles).isEmpty();
    assertThat(javaImportResult.libraries).isEmpty();
    assertThat(scalaImportResult.libraries).isEmpty();
}
Also used : BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) BlazeScalaImportResult(com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult) 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