diff options
author | kmb <kmb@google.com> | 2017-12-06 14:28:31 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-06 14:30:04 -0800 |
commit | 704d6ada9a17111879fec62bd7063a8a8a687b72 (patch) | |
tree | 25c86a62a181266abd1d21baab1661e3d19b2520 /src/test/java/com/google/devtools/build/android/dexer/DexFileSplitterTest.java | |
parent | 6ac92f9884ffd0bb46e4a5054ffd0311dc479571 (diff) |
Support inclusion filter in DexFileSplitter, with the same semantics as in ../ziputils/DexMapper.
RELNOTES: None.
PiperOrigin-RevId: 178153254
Diffstat (limited to 'src/test/java/com/google/devtools/build/android/dexer/DexFileSplitterTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/android/dexer/DexFileSplitterTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/android/dexer/DexFileSplitterTest.java b/src/test/java/com/google/devtools/build/android/dexer/DexFileSplitterTest.java index c2354ca134..29cd4c1645 100644 --- a/src/test/java/com/google/devtools/build/android/dexer/DexFileSplitterTest.java +++ b/src/test/java/com/google/devtools/build/android/dexer/DexFileSplitterTest.java @@ -99,6 +99,7 @@ public class DexFileSplitterTest { ImmutableList<Path> outputArchives = runDexSplitter( 200, + /*inclusionFilterJar=*/ null, "main_dex_list", MAIN_DEX_LIST_FILE, /*minimalMainDex=*/ false, @@ -117,6 +118,7 @@ public class DexFileSplitterTest { ImmutableList<Path> outputArchives = runDexSplitter( 256 * 256, + /*inclusionFilterJar=*/ null, "minimal_main_dex", MAIN_DEX_LIST_FILE, /*minimalMainDex=*/ true, @@ -129,6 +131,24 @@ public class DexFileSplitterTest { assertExpectedEntries(outputArchives, expectedEntries); } + @Test + public void testInclusionFilterJar() throws Exception { + Path dexArchive = buildDexArchive(); + Path dexArchive2 = buildDexArchive(INPUT_JAR2, "jar2.dex.zip"); + ImmutableList<Path> outputArchives = + runDexSplitter( + 256 * 256, + INPUT_JAR2, + "filtered", + /*mainDexList=*/ null, + /*minimalMainDex=*/ false, + dexArchive, + dexArchive2); + + // Only expect entries from the Jar we filtered by + assertExpectedEntries(outputArchives, dexEntries(dexArchive2)); + } + private static Iterable<String> expectedMainDexEntries() throws IOException { return Iterables.transform( Files.readAllLines(MAIN_DEX_LIST_FILE), @@ -146,6 +166,7 @@ public class DexFileSplitterTest { try { runDexSplitter( 200, + /*inclusionFilterJar=*/ null, "should_fail", /*mainDexList=*/ null, /*minimalMainDex=*/ true, @@ -183,6 +204,7 @@ public class DexFileSplitterTest { Path... dexArchives) throws IOException { return runDexSplitter( maxNumberOfIdxPerDex, + /*inclusionFilterJar=*/ null, outputRoot, /*mainDexList=*/ null, /*minimalMainDex=*/ false, @@ -191,6 +213,7 @@ public class DexFileSplitterTest { private ImmutableList<Path> runDexSplitter( int maxNumberOfIdxPerDex, + @Nullable Path inclusionFilterJar, String outputRoot, @Nullable Path mainDexList, boolean minimalMainDex, @@ -203,6 +226,7 @@ public class DexFileSplitterTest { options.maxNumberOfIdxPerDex = maxNumberOfIdxPerDex; options.mainDexListFile = mainDexList; options.minimalMainDex = minimalMainDex; + options.inclusionFilterJar = inclusionFilterJar; DexFileSplitter.splitIntoShards(options); assertThat(options.outputDirectory.toFile().exists()).isTrue(); ImmutableSet<Path> files = |