Search in sources :

Example 1 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimpleCCTest.

@Test
public void testSimpleCCTest() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_test(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
    assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
    assertThat(targetIdeInfo.getKindString()).isEqualTo("cc_test");
    assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(1);
    assertThat(relativePathsForCSourcesOf(targetIdeInfo)).containsExactly("com/google/example/simple/simple.cc");
    assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
    assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
    assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
    CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
    assertThat(cTargetIdeInfo.getTargetCoptList()).isEmpty();
    assertThat(cTargetIdeInfo.getTargetDefineList()).isEmpty();
    assertThat(cTargetIdeInfo.getTargetIncludeList()).isEmpty();
    assertThat(targetIdeInfo.getJavaIdeInfo().getJarsList()).isEmpty();
    assertThat(getIdeResolveFiles()).isEmpty();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 2 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSourceFilesAreCorrectlyMarkedAsSourceOrGenerated.

@Test
public void testSourceFilesAreCorrectlyMarkedAsSourceOrGenerated() throws Exception {
    scratch.file("com/google/example/BUILD", "genrule(", "   name = 'gen',", "   outs = ['gen.java'],", "   cmd = '',", ")", "java_library(", "    name = 'lib',", "    srcs = ['Test.java', ':gen'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib");
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib", targetIdeInfos);
    // todo(dslomov): Skylark aspect implementation does not yet return a correct root path.
    assertThat(targetIdeInfo.getJavaIdeInfo().getSourcesList()).containsExactly(ArtifactLocation.newBuilder().setRootExecutionPathFragment(targetConfig.getGenfilesDirectory(RepositoryName.MAIN).getExecPathString()).setRelativePath("com/google/example/gen.java").setIsSource(false).build(), ArtifactLocation.newBuilder().setRelativePath("com/google/example/Test.java").setIsSource(true).build());
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testPyTestWithDeps.

@Test
public void testPyTestWithDeps() throws Exception {
    scratch.file("com/google/example/BUILD", "py_library(", "    name = 'lib',", "    srcs = ['lib.py'],", ")", "py_test(", "    name = 'test',", "    srcs = ['test.py'],", "    deps = [':lib'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:test");
    assertThat(targetIdeInfos).hasSize(3);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:test", targetIdeInfos);
    ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
    assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
    assertThat(targetIdeInfo.getKindString()).isEqualTo("py_test");
    assertThat(targetIdeInfo.getDependenciesList()).contains("//com/google/example:lib");
    assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(2);
    assertThat(relativePathsForPySourcesOf(targetIdeInfo)).containsExactly("com/google/example/test.py");
    assertThat(targetIdeInfo.hasPyIdeInfo()).isTrue();
    assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
    assertThat(targetIdeInfo.hasCIdeInfo()).isFalse();
    assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
    assertThat(getIdeResolveFiles()).containsExactly("com/google/example/test.py", "com/google/example/lib.py");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 4 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testJavaImportWithExports.

@Test
public void testJavaImportWithExports() throws Exception {
    scratch.file("com/google/example/BUILD", "java_library(", "   name = 'foobar',", "   srcs = ['FooBar.java'],", ")", "java_import(", "   name = 'imp',", "   jars = ['a.jar', 'b.jar'],", "   deps = [':foobar'],", "   exports = [':foobar'],", ")", "java_library(", "   name = 'lib',", "   srcs = ['Lib.java'],", "   deps = [':imp'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib");
    TargetIdeInfo libInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib", targetIdeInfos);
    TargetIdeInfo impInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:imp", targetIdeInfos);
    assertThat(impInfo.getKindString()).isEqualTo("java_import");
    assertThat(impInfo.getDependenciesList()).contains("//com/google/example:foobar");
    assertThat(libInfo.getDependenciesList()).containsAllOf("//com/google/example:foobar", "//com/google/example:imp");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 5 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimpleCCLibraryWithIncludes.

@Test
public void testSimpleCCLibraryWithIncludes() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", "    includes = ['foo/bar'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
    CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
    assertThat(cTargetIdeInfo.getTargetIncludeList()).containsExactly("foo/bar");
    // Make sure our understanding of where this attributes show up in other providers is correct.
    Entry<String, TargetIdeInfo> toolchainEntry = getCcToolchainRuleAndVerifyThereIsOnlyOne(targetIdeInfos);
    TargetIdeInfo toolchainInfo = toolchainEntry.getValue();
    assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue();
    CToolchainIdeInfo cToolchainIdeInfo = toolchainInfo.getCToolchainIdeInfo();
    ProtocolStringList builtInIncludeDirectoryList = cToolchainIdeInfo.getBuiltInIncludeDirectoryList();
    assertThat(builtInIncludeDirectoryList).doesNotContain("foo/bar");
    assertThat(builtInIncludeDirectoryList).doesNotContain("com/google/example/foo/bar");
    ProtocolStringList transIncludeDirList = cTargetIdeInfo.getTransitiveIncludeDirectoryList();
    assertThat(transIncludeDirList).doesNotContain("foo/bar");
    assertThat(transIncludeDirList).doesNotContain("com/google/example/foo/bar");
    ProtocolStringList transQuoteIncludeDirList = cTargetIdeInfo.getTransitiveQuoteIncludeDirectoryList();
    assertThat(transQuoteIncludeDirList).doesNotContain("foo/bar");
    assertThat(transQuoteIncludeDirList).doesNotContain("com/google/example/foo/bar");
    ProtocolStringList transSysIncludeDirList = cTargetIdeInfo.getTransitiveSystemIncludeDirectoryList();
    assertThat(transSysIncludeDirList).doesNotContain("foo/bar");
    assertThat(transSysIncludeDirList).contains("com/google/example/foo/bar");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) CToolchainIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CToolchainIdeInfo) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) ByteString(com.google.protobuf.ByteString) ProtocolStringList(com.google.protobuf.ProtocolStringList) Test(org.junit.Test)

Aggregations

TargetIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo)58 ByteString (com.google.protobuf.ByteString)55 Test (org.junit.Test)55 ArtifactLocation (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation)12 CIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo)10 ProtocolStringList (com.google.protobuf.ProtocolStringList)7 CToolchainIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CToolchainIdeInfo)5 JavaIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.JavaIdeInfo)3 Artifact (com.google.devtools.build.lib.actions.Artifact)2 LibraryArtifact (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.LibraryArtifact)2 Action (com.google.devtools.build.lib.actions.Action)1 BinaryFileWriteAction (com.google.devtools.build.lib.analysis.actions.BinaryFileWriteAction)1 SpawnAction (com.google.devtools.build.lib.analysis.actions.SpawnAction)1 AndroidIdeInfoProvider (com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider)1 CcToolchainProvider (com.google.devtools.build.lib.rules.cpp.CcToolchainProvider)1 CppCompilationContext (com.google.devtools.build.lib.rules.cpp.CppCompilationContext)1 CppConfiguration (com.google.devtools.build.lib.rules.cpp.CppConfiguration)1 JavaRuleOutputJarsProvider (com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider)1 JavaToolchainProvider (com.google.devtools.build.lib.rules.java.JavaToolchainProvider)1 TestInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TestInfo)1