Commit 00a6b6ef authored by Skylot's avatar Skylot

core: add tests options, change log format

parent 04ac3b2e
...@@ -21,10 +21,12 @@ import static junit.framework.Assert.fail; ...@@ -21,10 +21,12 @@ import static junit.framework.Assert.fail;
public abstract class InternalJadxTest { public abstract class InternalJadxTest {
protected boolean outputCFG = false;
protected String outDir = "test-out-tmp";
public ClassNode getClassNode(Class<?> clazz) { public ClassNode getClassNode(Class<?> clazz) {
try { try {
File temp = getJarForClass(clazz); File temp = getJarForClass(clazz);
Decompiler d = new Decompiler(); Decompiler d = new Decompiler();
try { try {
d.loadFile(temp); d.loadFile(temp);
...@@ -34,14 +36,23 @@ public abstract class InternalJadxTest { ...@@ -34,14 +36,23 @@ public abstract class InternalJadxTest {
} finally { } finally {
temp.delete(); temp.delete();
} }
List<ClassNode> classes = d.getRoot().getClasses(false); List<ClassNode> classes = d.getRoot().getClasses(false);
ClassNode cls = classes.get(0); ClassNode cls = classes.get(0);
assertEquals(cls.getFullName(), clazz.getName()); assertEquals(cls.getFullName(), clazz.getName());
cls.load(); 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) { for (IDexTreeVisitor visitor : passes) {
DepthTraverser.visit(visitor, cls); DepthTraverser.visit(visitor, cls);
} }
...@@ -78,10 +89,10 @@ public abstract class InternalJadxTest { ...@@ -78,10 +89,10 @@ public abstract class InternalJadxTest {
String path = cutPackage(cls) + ".class"; String path = cutPackage(cls) + ".class";
URL resource = cls.getResource(path); URL resource = cls.getResource(path);
if (resource == null) { if (resource == null) {
throw new AssertionError("Class file not found: " + path); fail("Class file not found: " + path);
} }
if (!"file".equalsIgnoreCase(resource.getProtocol())) { 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()); return new File(resource.getPath());
} }
...@@ -109,8 +120,9 @@ public abstract class InternalJadxTest { ...@@ -109,8 +120,9 @@ public abstract class InternalJadxTest {
} }
target.closeEntry(); target.closeEntry();
} finally { } finally {
if (in != null) if (in != null) {
in.close(); 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% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment