Don't propagate exceptions from RoundtripTest.runTest()

This commit is contained in:
Ben Gruver 2015-03-17 21:14:24 -07:00 committed by Connor Tumbleson
parent ce8a993bc7
commit a01bf8c832
2 changed files with 23 additions and 17 deletions

View File

@ -31,11 +31,8 @@
package org.jf.baksmali;
import org.antlr.runtime.RecognitionException;
import org.junit.Test;
import java.io.IOException;
public class LambdaTest extends IdenticalRoundtripTest {
private baksmaliOptions createOptions() {
@ -46,7 +43,7 @@ public class LambdaTest extends IdenticalRoundtripTest {
}
@Test
public void testHelloWorldLambda() throws IOException, RecognitionException {
public void testHelloWorldLambda() {
runTest("HelloWorldLambda", createOptions());
}
}

View File

@ -70,20 +70,29 @@ public abstract class RoundtripTest {
return String.format("%s%s%sOutput.smali", testDir, File.separatorChar, testName);
}
protected void runTest(@Nonnull String testName, @Nonnull baksmaliOptions options)
throws IOException, RecognitionException {
// Load file from resources as a stream
String inputFilename = getInputFilename(testName);
String input = readResourceFully(getInputFilename(testName));
String output;
if (getOutputFilename(testName).equals(inputFilename)) {
output = input;
} else {
output = readResourceFully(getOutputFilename(testName));
}
protected void runTest(@Nonnull String testName) {
runTest(testName, new baksmaliOptions());
}
// Run smali, baksmali, and then compare strings are equal (minus comments/whitespace)
BaksmaliTestUtils.assertSmaliCompiledEquals(input, output, options, true);
protected void runTest(@Nonnull String testName, @Nonnull baksmaliOptions options) {
try {
// Load file from resources as a stream
String inputFilename = getInputFilename(testName);
String input = readResourceFully(getInputFilename(testName));
String output;
if (getOutputFilename(testName).equals(inputFilename)) {
output = input;
} else {
output = readResourceFully(getOutputFilename(testName));
}
// Run smali, baksmali, and then compare strings are equal (minus comments/whitespace)
BaksmaliTestUtils.assertSmaliCompiledEquals(input, output, options, true);
} catch (IOException ex) {
Assert.fail();
} catch (RecognitionException ex) {
Assert.fail();
}
}
@Nonnull