Commit 7527399e authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Speed up incremental install test listing by looking only in test dexes

On my machine, this sped up the test listing step by 50% according to
the timestamps from bin/run_chrome_public_test_apk_incremental -v.

While this is a heuristic, I tested that it finds all tests for
chrome_public_test_apk, and if it does ever miss some tests, it won't
affect bots, so the error will happen only locally.

Change-Id: If227a3b08963d8899839bd6d661f0f392ff1cd5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1777092Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692122}
parent 012d7007
...@@ -31,6 +31,7 @@ import org.chromium.base.annotations.MainDex; ...@@ -31,6 +31,7 @@ import org.chromium.base.annotations.MainDex;
import org.chromium.base.multidex.ChromiumMultiDexInstaller; import org.chromium.base.multidex.ChromiumMultiDexInstaller;
import org.chromium.base.test.util.InMemorySharedPreferencesContext; import org.chromium.base.test.util.InMemorySharedPreferencesContext;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -213,12 +214,25 @@ public class BaseChromiumAndroidJUnitRunner extends AndroidJUnitRunner { ...@@ -213,12 +214,25 @@ public class BaseChromiumAndroidJUnitRunner extends AndroidJUnitRunner {
} }
private TestRequest createListTestRequest(Bundle arguments) { private TestRequest createListTestRequest(Bundle arguments) {
List<DexFile> dexFiles = new ArrayList<>(); ArrayList<DexFile> dexFiles = new ArrayList<>();
try { try {
Class<?> bootstrapClass = Class<?> bootstrapClass =
Class.forName("org.chromium.incrementalinstall.BootstrapApplication"); Class.forName("org.chromium.incrementalinstall.BootstrapApplication");
dexFiles = Arrays.asList( DexFile[] incrementalInstallDexes =
(DexFile[]) bootstrapClass.getDeclaredField("sIncrementalDexFiles").get(null)); (DexFile[]) bootstrapClass.getDeclaredField("sIncrementalDexFiles").get(null);
// The incremental install dex files contain directory paths in their names. e.g.:
// third_party.android_deps.com_android_support_gridlayout_v7_java__classes.dex.jar
// Skipping application and system dex files speeds up test listing 12s -> 6s on my
// Pixel 1 running Q.
for (DexFile dexFile : incrementalInstallDexes) {
if (dexFile.getName().startsWith("/system")) {
continue;
}
String baseName = new File(dexFile.getName()).getName();
if (baseName.contains("test") || baseName.contains("Test")) {
dexFiles.add(dexFile);
}
}
} catch (Exception e) { } catch (Exception e) {
// Not an incremental apk. // Not an incremental apk.
if (BuildConfig.IS_MULTIDEX_ENABLED if (BuildConfig.IS_MULTIDEX_ENABLED
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment