diff options
author | jingwen <jingwen@google.com> | 2017-12-13 17:38:06 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-13 17:39:28 -0800 |
commit | 70b6e5d7df8130f4e622e1ff9c1cd224d208d00e (patch) | |
tree | 3ac4745537b6577542189e6310f5b2c041b836d7 /src/test/java/com/google/devtools/build/lib/rules | |
parent | c6557ea56476fd56ee94f2476ac01849841bcaf0 (diff) |
Perform ZipFilterAction on the instrumentation JAR using the target JAR as filter. .class and R.class files are filtered out.
During an instrumentation test, jars from both APKS will be loaded onto the same classloader by ART. To prevent runtime crashes due to duplicate classes, we strip the dupe class out from the instrumentation jar.
GITHUB: #903
RELNOTES: None.
PiperOrigin-RevId: 178983712
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java | 33 |
1 files changed, 33 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 7cdd63005e..0d67beb862 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 @@ -4076,6 +4076,39 @@ public class AndroidBinaryTest extends AndroidBuildViewTestCase { assertThat(provider).isNull(); } + @Test + public void testFilterActionWithInstrumentedBinary() throws Exception { + scratch.file( + "java/com/google/android/instr/BUILD", + "android_binary(name = 'b1',", + " srcs = ['b1.java'],", + " instruments = ':b2',", + " manifest = 'AndroidManifest.xml')", + "android_binary(name = 'b2',", + " srcs = ['b2.java'],", + " manifest = 'AndroidManifest.xml')"); + ConfiguredTarget b1 = getConfiguredTarget("//java/com/google/android/instr:b1"); + SpawnAction action = + (SpawnAction) + actionsTestUtil().getActionForArtifactEndingWith(getFilesToBuild(b1), "_filtered.jar"); + assertThat(action.getArguments()) + .containsAllOf( + "--inputZip", + getFirstArtifactEndingWith(action.getInputs(), "b1_deploy.jar").getExecPathString(), + "--filterZips", + getFirstArtifactEndingWith(action.getInputs(), "b2_deploy.jar").getExecPathString(), + "--outputZip", + getFirstArtifactEndingWith(action.getOutputs(), "b1_filtered.jar").getExecPathString(), + "--filterTypes", + ".class", + "--checkHashMismatch", + "IGNORE", + "--explicitFilters", + "R\\.class,R\\$.*\\.class", + "--outputMode", + "DONT_CARE"); + } + /** * 'proguard_specs' attribute gets read by an implicit outputs function: the * current heuristic is that if this attribute is configurable, we assume its |