aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-03-05 15:38:41 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-05 15:41:02 -0800
commitd2cf5cab8390c8057d8240bce8abdd61d6e1d916 (patch)
treec3eb28a2c331710ac8091b870923ef475e7313f2 /src/test/java/com/google/devtools/build
parent922d1e671bc02086afdcfb8ae1636eefc53e0ee2 (diff)
Add --experimental_fix_deps_tool flag to Bazel
RELNOTES: None PiperOrigin-RevId: 187936071
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java50
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java19
2 files changed, 69 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
index 814a46fa32..1b5a01cc1d 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
@@ -2830,6 +2830,56 @@ public class AndroidBinaryTest extends AndroidBuildViewTestCase {
}
@Test
+ public void testFixDepsToolFlag() throws Exception {
+ useConfiguration("--experimental_fix_deps_tool=autofixer");
+
+ scratch.file("java/foo/A.java", "foo");
+ scratch.file(
+ "java/foo/BUILD",
+ "android_binary(name = 'a', manifest = 'AndroidManifest.xml', ",
+ " srcs = ['A.java'])");
+
+ Iterable<String> commandLine =
+ ((JavaCompileAction)
+ actionsTestUtil()
+ .getActionForArtifactEndingWith(
+ actionsTestUtil()
+ .artifactClosureOf(
+ getGeneratingAction(
+ getFileConfiguredTarget("//java/foo:a_deploy.jar")
+ .getArtifact())
+ .getInputs()),
+ "liba.jar"))
+ .buildCommandLine();
+
+ assertThat(commandLine).containsAllOf("--experimental_fix_deps_tool", "autofixer").inOrder();
+ }
+
+ @Test
+ public void testFixDepsToolFlagEmpty() throws Exception {
+ scratch.file("java/foo/A.java", "foo");
+ scratch.file(
+ "java/foo/BUILD",
+ "android_binary(name = 'a', manifest = 'AndroidManifest.xml', ",
+ " srcs = ['A.java'])");
+
+ Iterable<String> commandLine =
+ ((JavaCompileAction)
+ actionsTestUtil()
+ .getActionForArtifactEndingWith(
+ actionsTestUtil()
+ .artifactClosureOf(
+ getGeneratingAction(
+ getFileConfiguredTarget("//java/foo:a_deploy.jar")
+ .getArtifact())
+ .getInputs()),
+ "liba.jar"))
+ .buildCommandLine();
+
+ assertThat(commandLine).containsAllOf("--experimental_fix_deps_tool", "add_dep").inOrder();
+ }
+
+ @Test
public void testAndroidBinaryExportsJavaCompilationArgsProvider() throws Exception {
scratch.file("java/foo/A.java", "foo");
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java
index 18079f71e3..d99b56d292 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java
@@ -211,6 +211,25 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
}
@Test
+ public void testFixDepsToolEmpty() throws Exception {
+ scratch.file("java/android/BUILD", "android_library(name = 'b', srcs = ['B.java'])");
+ List<String> commandLine =
+ getGeneratingSpawnActionArgs(
+ getFileConfiguredTarget("//java/android:libb.jar").getArtifact());
+ assertThat(commandLine).containsAllOf("--experimental_fix_deps_tool", "add_dep").inOrder();
+ }
+
+ @Test
+ public void testFixDepsTool() throws Exception {
+ useConfiguration("--experimental_fix_deps_tool=auto_fixer");
+ scratch.file("java/android/BUILD", "android_library(name = 'b', srcs = ['B.java'])");
+ List<String> commandLine =
+ getGeneratingSpawnActionArgs(
+ getFileConfiguredTarget("//java/android:libb.jar").getArtifact());
+ assertThat(commandLine).containsAllOf("--experimental_fix_deps_tool", "auto_fixer").inOrder();
+ }
+
+ @Test
public void testJavaPluginProcessorPath() throws Exception {
scratch.file("java/test/BUILD",
"java_library(name = 'plugin_dep',",