未验证 提交 00b48473 编写于 作者: S Skylot

test: add internal option to disable file save

上级 84facb13
......@@ -93,6 +93,11 @@ public class JadxArgs {
private UseKotlinMethodsForVarNames useKotlinMethodsForVarNames = UseKotlinMethodsForVarNames.APPLY;
/**
* Don't save files (can be using for performance testing)
*/
private boolean skipFilesSave = false;
public JadxArgs() {
// use default options
}
......@@ -447,6 +452,14 @@ public class JadxArgs {
this.useKotlinMethodsForVarNames = useKotlinMethodsForVarNames;
}
public boolean isSkipFilesSave() {
return skipFilesSave;
}
public void setSkipFilesSave(boolean skipFilesSave) {
this.skipFilesSave = skipFilesSave;
}
@Override
public String toString() {
return "JadxArgs{" + "inputFiles=" + inputFiles
......
......@@ -282,6 +282,9 @@ public final class JadxDecompiler implements Closeable {
}
private void appendResourcesSaveTasks(List<Runnable> tasks, File outDir) {
if (args.isSkipFilesSave()) {
return;
}
Set<String> inputFileNames = args.getInputFiles().stream().map(File::getAbsolutePath).collect(Collectors.toSet());
for (ResourceFile resourceFile : getResources()) {
if (resourceFile.getType() != ResourceType.ARSC
......
......@@ -34,6 +34,9 @@ public class SaveCode {
if (codeStr.isEmpty()) {
return;
}
if (cls.root().getArgs().isSkipFilesSave()) {
return;
}
String fileName = cls.getClassInfo().getAliasFullPath() + getFileExtension(cls);
save(codeStr, dir, fileName);
}
......
......@@ -14,10 +14,10 @@ import jadx.api.ICodeWriter;
import jadx.api.JadxArgs;
import jadx.api.JadxDecompiler;
import jadx.api.JadxInternalAccess;
import jadx.api.JavaClass;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.core.dex.nodes.RootNode;
import jadx.core.utils.DebugChecks;
import jadx.core.utils.exceptions.JadxRuntimeException;
import jadx.tests.api.IntegrationTest;
......@@ -35,9 +35,13 @@ public abstract class BaseExternalTest extends IntegrationTest {
}
protected JadxArgs prepare(File input) {
DebugChecks.checksEnabled = false;
JadxArgs args = new JadxArgs();
args.getInputFiles().add(input);
args.setOutDir(new File("../jadx-external-tests-tmp"));
args.setSkipFilesSave(true);
args.setSkipResources(true);
args.setShowInconsistentCode(true);
return args;
}
......@@ -54,8 +58,7 @@ public abstract class BaseExternalTest extends IntegrationTest {
jadx.load();
if (clsPatternStr == null) {
processAll(jadx);
// jadx.saveSources();
jadx.save();
} else {
processByPatterns(jadx, clsPatternStr, mthPatternStr);
}
......@@ -63,16 +66,6 @@ public abstract class BaseExternalTest extends IntegrationTest {
return jadx;
}
private void processAll(JadxDecompiler jadx) {
for (JavaClass javaClass : jadx.getClasses()) {
try {
javaClass.decompile();
} catch (Exception e) {
LOG.error("Failed to decompile class: {}", javaClass, e);
}
}
}
private void processByPatterns(JadxDecompiler jadx, String clsPattern, @Nullable String mthPattern) {
RootNode root = JadxInternalAccess.getRoot(jadx);
int processed = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册