aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-03-24 03:12:29 +0000
committerGravatar Yue Gan <yueg@google.com>2017-03-24 12:19:27 +0000
commit5e1a420f1b385382a2df5359faf3ae773aa8d61e (patch)
tree8736029d0bf4beebaffa46af230ab4834738caa8 /src/test
parent58a615c4941e041d68bceeb68b0d77269f6143f5 (diff)
*** Reason for rollback *** Rolling forward with the correct changes to the AndroidResourceMergingAction. Tested manually. *** Original change description *** Automated [] rollback of commit a58f245a4b40c0ef961b1f30d96b16a9349711c3. *** Reason for rollback *** broke over 100k targets, in the depot, see [] *** Original change description *** Move library R generation to a separate action, ensuring the merging happens off the java critical path. -- PiperOrigin-RevId: 151087737 MOS_MIGRATED_REVID=151087737
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java77
1 files changed, 50 insertions, 27 deletions
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 52cd935e2e..8bba37d7d1 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
@@ -718,8 +718,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
"<resources><string name = 'hello'>Hello Android!</string></resources>");
ConfiguredTarget resource = getConfiguredTarget("//c/b/m/a:r");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(resource, ImmutableList.of("c/b/m/a/b_/res"), args);
}
@@ -734,8 +736,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
"<resources><string name = 'hello'>Hello Android!</string></resources>");
ConfiguredTarget resource = getConfiguredTarget("//java/android:r");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(resource, ImmutableList.of("java/android/res"), args);
}
@@ -752,8 +756,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
"<resources><string name = 'hello'>Hello Android!</string></resources>");
ConfiguredTarget resource = getConfiguredTarget("//java/android:r");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(resource, ImmutableList.of("java/android/res"), args);
}
@@ -768,8 +774,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
"exports_files(['res/values/strings.xml'])");
ConfiguredTarget resource = getConfiguredTarget("//java/android:r");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(resource, ImmutableList.of("java/other/res"), args);
assertNoEvents();
}
@@ -787,8 +795,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
")");
ConfiguredTarget resource = getConfiguredTarget("//java/android:r");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(resource, ImmutableList.of("java/other/res"), args);
assertNoEvents();
}
@@ -807,8 +817,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
"exports_files(['res/values/strings.xml'])");
ConfiguredTarget resource = getConfiguredTarget("//java/android:r");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(resource, ImmutableList.of("java/other/res"), args);
assertNoEvents();
}
@@ -829,8 +841,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
")");
ConfiguredTarget resource = getConfiguredTarget("//java/android:r");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(resource, ImmutableList.of("java/other/res"), args);
assertNoEvents();
}
@@ -1072,22 +1086,27 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
target.getProvider(AndroidResourcesProvider.class).getDirectAndroidResources());
SpawnAction resourceParserAction =
- (SpawnAction)
- actionsTestUtil()
- .getActionForArtifactEndingWith(artifacts,
- "/" + resources.getSymbols().getFilename());
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(target, AndroidRuleClasses.ANDROID_MERGED_SYMBOLS));
+
+ SpawnAction mergeAction =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(target, AndroidRuleClasses.ANDROID_RESOURCES_ZIP));
+
SpawnAction resourceClassJarAction =
(SpawnAction)
actionsTestUtil()
- .getActionForArtifactEndingWith(artifacts,
- "/" + resources.getJavaClassJar().getFilename());
+ .getActionForArtifactEndingWith(
+ artifacts, "/" + resources.getJavaClassJar().getFilename());
+
SpawnAction resourceSrcJarAction =
(SpawnAction)
actionsTestUtil()
- .getActionForArtifactEndingWith(artifacts,
- "/" + resources.getJavaSourceJar().getFilename());
+ .getActionForArtifactEndingWith(
+ artifacts, "/" + resources.getJavaSourceJar().getFilename());
assertThat(resourceParserAction.getMnemonic()).isEqualTo("AndroidResourceParser");
- assertThat(resourceClassJarAction.getMnemonic()).isEqualTo("AndroidResourceMerger");
+ assertThat(mergeAction.getMnemonic()).isEqualTo("AndroidResourceMerger");
+ assertThat(resourceClassJarAction.getMnemonic()).isEqualTo("LibraryRClassGenerator");
assertThat(resourceSrcJarAction.getMnemonic()).isEqualTo("AndroidResourceValidator");
// Validator also generates an R.txt.
assertThat(resourceSrcJarAction.getOutputs()).contains(resources.getRTxt());
@@ -1357,8 +1376,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
" resource_files = ['d2-res/values/strings.xml'],",
" )");
ConfiguredTarget resource = getConfiguredTarget("//java/android/resources/d1:d1");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(resource, ImmutableList.of("java/android/resources/d1/d1-res"), args);
Truth.assertThat(getDirectDependentResourceDirs(resource, args))
.contains("java/android/resources/d2/d2-res");
@@ -1395,8 +1416,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
" )");
ConfiguredTarget resource = getConfiguredTarget("//java/android/resources/d1:d1");
- List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource)))
- .getArguments();
+ List<String> args =
+ getGeneratingSpawnAction(
+ getImplicitOutputArtifact(resource, AndroidRuleClasses.ANDROID_RESOURCES_ZIP))
+ .getArguments();
assertPrimaryResourceDirs(
resource, ImmutableList.of("java/android/resources/d1/d1-res"), args);
Truth.assertThat(getDirectDependentResourceDirs(resource, args))