Search in sources :

Example 6 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testSimpleCCBinary.

@Test
public void testSimpleCCBinary() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_binary(", "    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_binary");
    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 7 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testSimpleCCLibrary.

@Test
public void testSimpleCCLibrary() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", ")");
    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_library");
    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();
    ProtocolStringList transQuoteIncludeDirList = cTargetIdeInfo.getTransitiveQuoteIncludeDirectoryList();
    assertThat(transQuoteIncludeDirList).contains(".");
    assertThat(targetIdeInfo.getJavaIdeInfo().getJarsList()).isEmpty();
    assertThat(getIdeResolveFiles()).containsExactly("com/google/example/simple/simple.h");
}
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) ProtocolStringList(com.google.protobuf.ProtocolStringList) Test(org.junit.Test)

Example 8 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testSimpleCCLibraryForCCToolchainExistence.

@Test
public void testSimpleCCLibraryForCCToolchainExistence() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo target = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    Entry<String, TargetIdeInfo> toolchainEntry = getCcToolchainRuleAndVerifyThereIsOnlyOne(targetIdeInfos);
    TargetIdeInfo toolchainInfo = toolchainEntry.getValue();
    ArtifactLocation location = target.getBuildFileArtifactLocation();
    assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
    assertThat(target.hasCIdeInfo()).isTrue();
    assertThat(target.getDependenciesList()).hasSize(1);
    assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue();
}
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 9 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testNonExternalRootCorrectlyIdentified.

@Test
public void testNonExternalRootCorrectlyIdentified() throws Exception {
    ArtifactLocation location = AndroidStudioInfoAspect.makeArtifactLocation(Root.asSourceRoot(rootDirectory, true), new PathFragment("foo/bar.jar"), false);
    assertThat(location.getIsExternal()).isFalse();
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) Test(org.junit.Test)

Example 10 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testCcToolchainInfoIsOnlyPresentForToolchainRules.

@Test
public void testCcToolchainInfoIsOnlyPresentForToolchainRules() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    Entry<String, TargetIdeInfo> toolchainEntry = getCcToolchainRuleAndVerifyThereIsOnlyOne(targetIdeInfos);
    TargetIdeInfo toolchainInfo = toolchainEntry.getValue();
    ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
    assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
    assertThat(targetIdeInfo.hasCToolchainIdeInfo()).isFalse();
    assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue();
}
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)

Aggregations

ArtifactLocation (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation)15 Test (org.junit.Test)14 TargetIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo)12 ByteString (com.google.protobuf.ByteString)12 CIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo)3 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)2 Artifact (com.google.devtools.build.lib.actions.Artifact)1 SourceDirectory (com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider.SourceDirectory)1 OutputJar (com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider.OutputJar)1 AndroidIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.AndroidIdeInfo)1 JavaIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.JavaIdeInfo)1 LibraryArtifact (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.LibraryArtifact)1 ProtocolStringList (com.google.protobuf.ProtocolStringList)1