From 0b1279a79a9d7b17e6fd8a1ad2558cc4e3a4d22f Mon Sep 17 00:00:00 2001 From: Jean-Marie Henaff Date: Mon, 13 Oct 2014 15:35:33 +0200 Subject: Use Jill via API for tests. Using the built version requires to rebuilt project with Ant before launching the JUnit tests from within Eclipse. Change-Id: Idd9a7810952aedb374af29e21a6118af3cb66f53 --- jill/tests/com/android/jill/JillTestTools.java | 41 +++++++++----------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'jill/tests') diff --git a/jill/tests/com/android/jill/JillTestTools.java b/jill/tests/com/android/jill/JillTestTools.java index dd6c19c..c2a0e90 100644 --- a/jill/tests/com/android/jill/JillTestTools.java +++ b/jill/tests/com/android/jill/JillTestTools.java @@ -18,11 +18,9 @@ package com.android.jill; import com.android.jack.DexComparator; import com.android.jack.JarJarRules; -import com.android.jack.Options; import com.android.jack.ProguardFlags; import com.android.jack.TestTools; import com.android.jack.backend.dex.DexFileWriter; -import com.android.jack.util.ExecuteFile; import java.io.File; import java.io.IOException; @@ -49,36 +47,24 @@ public class JillTestTools extends TestTools { } public static void runJill(@Nonnull File inputFile, @Nonnull File outputFile) throws Exception { - String[] args = new String[] {"java", - "-jar", - JILL.getAbsolutePath(), - "-o", - outputFile.getAbsolutePath(), - inputFile.getAbsolutePath()}; + String[] args = new String[] { + "-o", + outputFile.getAbsolutePath(), + inputFile.getAbsolutePath()}; - ExecuteFile execFile = new ExecuteFile(args); - if (!execFile.run()) { - throw new RuntimeException("Call to jill exited with an error"); - } + Options options = Main.getOptions(args); + new Jill(options, "").process(options.getBinaryFile()); } public static void runJillToZip(@Nonnull File inputFile, @Nonnull File outputFile) throws Exception { - String[] args = new String[] {"java", - "-jar", - JillTestTools.JILL.getAbsolutePath(), - "-o", + String[] args = new String[] {"-o", outputFile.getAbsolutePath(), inputFile.getAbsolutePath(), "-v", - "-c", "zip"}; - - ExecuteFile execFile = new ExecuteFile(args); - execFile.setErr(System.err); - execFile.setOut(System.out); - execFile.setVerbose(true); - if (!execFile.run()) { - throw new RuntimeException("Call to jill exited with an error"); - } + "-c", + "zip"}; + Options options = Main.getOptions(args); + new Jill(options, "").process(options.getBinaryFile()); } public static void checkStructureWithJill(@CheckForNull File[] refBootclasspath, @@ -100,7 +86,8 @@ public class JillTestTools extends TestTools { @CheckForNull JarJarRules jarjarRules, @CheckForNull ProguardFlags[] proguardFlags) throws Exception { - Options options = buildCommandLineArgs(bootclasspath, classpath, fileOrSourceList); + com.android.jack.Options options = + buildCommandLineArgs(bootclasspath, classpath, fileOrSourceList); boolean useEcjAsRefCompiler = withDebugInfo; @@ -134,7 +121,7 @@ public class JillTestTools extends TestTools { // Run Jack on .jack File jackDexFolder = TestTools.createTempDir("jack", "dex"); - compileJackToDex(new Options(), jackFile, jackDexFolder, false); + compileJackToDex(new com.android.jack.Options(), jackFile, jackDexFolder, false); // Compare Jack Dex file to reference new DexComparator(withDebugInfo, /* strict */false, /* compareDebugInfoBinary */ false, -- cgit v1.2.3