aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-12-06 15:15:57 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-12-06 15:24:53 +0000
commit304da48921ebca7a1948dac787c7cb95e31cc381 (patch)
treecf47bb972a1b2479cccce8f3e73dbc75ea381f85 /src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java
parent7dbcf5bee4a6664f78b440d4c702d1b8701c6aa8 (diff)
*** Reason for rollback *** This change make AndroidStudioInfoAspectTest#testAndroidLibrary flaky bazel test --nocache_test_results --runs_per_test 10 //src/test/java/com/google/devtools/build/lib:ideinfo_test gives 2 to 3 failures out of 10 run. Fixes #2192 *** Original change description *** Pass isExternal field to blaze ide info proto Roll forward after fixing tests. The intellij aspect tests now correctly retains the required toolchain targets in the WORKSPACE file. -- PiperOrigin-RevId: 141174688 MOS_MIGRATED_REVID=141174688
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java57
1 files changed, 1 insertions, 56 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java b/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java
index 649c3ff6b6..6d157edb7b 100644
--- a/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java
+++ b/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java
@@ -20,9 +20,7 @@ import static org.junit.Assert.assertNotNull;
import com.google.common.collect.Iterables;
import com.google.common.collect.ObjectArrays;
-import com.google.devtools.build.lib.actions.Root;
import com.google.devtools.build.lib.cmdline.RepositoryName;
-import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation;
import com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo;
import com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CToolchainIdeInfo;
@@ -62,7 +60,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase
assertThat(Paths.get(location.getRelativePath()).toString())
.isEqualTo(Paths.get("com/google/example/BUILD").toString());
assertThat(location.getIsSource()).isTrue();
- assertThat(location.getIsExternal()).isFalse();
assertThat(targetIdeInfo.getKindString()).isEqualTo("java_library");
assertThat(relativePathsForJavaSourcesOf(targetIdeInfo))
.containsExactly("com/google/example/simple/Simple.java");
@@ -100,6 +97,7 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase
} else {
assertEquals(packageManifest.getRelativePath(), "com/google/example/simple.java-manifest");
}
+
}
@Test
@@ -1814,59 +1812,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase
buildIdeInfo("//com/google/example:foo");
}
- @Test
- public void testExternalRootCorrectlyIdentified() throws Exception {
- ArtifactLocation location =
- AndroidStudioInfoAspect.makeArtifactLocation(
- Root.asSourceRoot(outputBase, false), new PathFragment("external/foo/bar.jar"));
- assertThat(location.getIsExternal()).isTrue();
- }
-
- @Test
- public void testNonExternalRootCorrectlyIdentified() throws Exception {
- ArtifactLocation location =
- AndroidStudioInfoAspect.makeArtifactLocation(
- Root.asSourceRoot(rootDirectory, true), new PathFragment("foo/bar.jar"));
- assertThat(location.getIsExternal()).isFalse();
- }
-
- @Test
- public void testExternalTarget() throws Exception {
- scratch.file(
- "/r/BUILD", "java_import(", " name = 'junit',", " jars = ['junit.jar'],", ")");
- scratch.file("/r/junit.jar");
-
- // AnalysisMock adds required toolchains, etc. to WORKSPACE, so retain the previous contents.
- String oldContents = scratch.readFile("WORKSPACE");
- scratch.overwriteFile("WORKSPACE", oldContents + "\nlocal_repository(name='r', path='/r')");
- invalidatePackages();
-
- scratch.file(
- "com/google/example/BUILD",
- "java_library(",
- " name = 'junit',",
- " exports = ['@r//:junit'],",
- ")");
-
- Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:junit");
- assertThat(
- getTargetIdeInfoAndVerifyLabel("//com/google/example:junit", targetIdeInfos)
- .getBuildFileArtifactLocation()
- .getIsExternal())
- .isFalse();
-
- TargetIdeInfo targetInfo = getTargetIdeInfoAndVerifyLabel("@r//:junit", targetIdeInfos);
- assertThat(targetInfo.getBuildFileArtifactLocation().getIsExternal()).isTrue();
- assertThat(targetInfo.getBuildFileArtifactLocation().getRelativePath()).startsWith("external");
-
- JavaIdeInfo javaInfo = targetInfo.getJavaIdeInfo();
- assertThat(javaInfo.getJarsList()).hasSize(1);
- ArtifactLocation jar = javaInfo.getJars(0).getJar();
- assertThat(jar.getIsSource()).isTrue();
- assertThat(jar.getIsExternal()).isTrue();
- assertThat(jar.getRelativePath()).isEqualTo("external/r/junit.jar");
- }
-
/**
* Returns true if we are testing the native aspect, not the Skylark one. Eventually Skylark
* aspect will be equivalent to a native one, and this method will be removed.