Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions runner/android_junit_runner/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

* Add logs at the start and end of RunBefore and RunAfters sections to help bug understanding. (b/445754263)

* Add opt-in DEX bytecode pre-filtering of candidate test classes to `AndroidClasspathSuite` via `-e useDexBytecodeScanner true`, speeding up test discovery on large APKs.

**Breaking Changes**

**API Changes**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,15 @@ public boolean accept(String className) {
}

private final Set<String> classPath = new HashSet<>();
private final boolean useDexBytecodePreFilter;

/**
* Constructs a new instance of a {@link ClassPathScanner}.
*
* @param paths filepaths that should be scanned (.apk and .dex files)
*/
public ClassPathScanner(String... paths) {
this(Arrays.asList(paths));
this(Arrays.asList(paths), /* useDexBytecodePreFilter= */ false);
}

/**
Expand All @@ -189,7 +190,20 @@ public ClassPathScanner(String... paths) {
* @param paths a list of paths that should be scanned (.apk and .dex files)
*/
public ClassPathScanner(Collection<String> paths) {
classPath.addAll(paths);
this(paths, /* useDexBytecodePreFilter= */ false);
}

/**
* Constructs a new instance of a {@link ClassPathScanner}.
*
* @param paths a list of paths that should be scanned (.apk and .dex files)
* @param useDexBytecodePreFilter if true, candidate test classes are pre-filtered by reading DEX
* bytecode tables via {@link DexBytecodeScanner}; otherwise every class is enumerated via
* {@link DexFile}
*/
public ClassPathScanner(Collection<String> paths, boolean useDexBytecodePreFilter) {
this.classPath.addAll(paths);
this.useDexBytecodePreFilter = useDexBytecodePreFilter;
}

/**
Expand All @@ -213,6 +227,9 @@ public static Collection<String> getDefaultClasspaths(Instrumentation instrument
*/
private void addEntriesFromPath(Set<String> entryNames, String path, ClassNameFilter filter)
throws IOException {
if (useDexBytecodePreFilter && DexBytecodeScanner.scanPath(entryNames, path, filter)) {
return;
}
DexFile dexFile = null;
try {
try {
Expand Down
Loading
Loading