提交 00a6b6ef 编写于 作者: S Skylot

core: add tests options, change log format

上级 04ac3b2e
......@@ -21,10 +21,12 @@ import static junit.framework.Assert.fail;
public abstract class InternalJadxTest {
protected boolean outputCFG = false;
protected String outDir = "test-out-tmp";
public ClassNode getClassNode(Class<?> clazz) {
try {
File temp = getJarForClass(clazz);
Decompiler d = new Decompiler();
try {
d.loadFile(temp);
......@@ -34,14 +36,23 @@ public abstract class InternalJadxTest {
} finally {
temp.delete();
}
List<ClassNode> classes = d.getRoot().getClasses(false);
ClassNode cls = classes.get(0);
assertEquals(cls.getFullName(), clazz.getName());
cls.load();
List<IDexTreeVisitor> passes = Jadx.getPassesList(new DefaultJadxArgs(), null);
List<IDexTreeVisitor> passes = Jadx.getPassesList(new DefaultJadxArgs() {
@Override
public boolean isCFGOutput() {
return outputCFG;
}
@Override
public boolean isRawCFGOutput() {
return outputCFG;
}
}, new File(outDir));
for (IDexTreeVisitor visitor : passes) {
DepthTraverser.visit(visitor, cls);
}
......@@ -78,10 +89,10 @@ public abstract class InternalJadxTest {
String path = cutPackage(cls) + ".class";
URL resource = cls.getResource(path);
if (resource == null) {
throw new AssertionError("Class file not found: " + path);
fail("Class file not found: " + path);
}
if (!"file".equalsIgnoreCase(resource.getProtocol())) {
throw new IllegalStateException("Class is not stored in a file.");
fail("Class is not stored in a file.");
}
return new File(resource.getPath());
}
......@@ -109,8 +120,9 @@ public abstract class InternalJadxTest {
}
target.closeEntry();
} finally {
if (in != null)
if (in != null) {
in.close();
}
}
}
}
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss} %-5level - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册