summaryrefslogtreecommitdiffstats
path: root/jack-tests
diff options
context:
space:
mode:
Diffstat (limited to 'jack-tests')
-rw-r--r--jack-tests/src/com/android/jack/test/toolchain/JackApiV01Toolchain.java51
-rw-r--r--jack-tests/tests/com/android/jack/multidex/MultiDexOverflowTests.java5
-rw-r--r--jack-tests/tests/com/android/jack/tools/merger/test011/MergerTest011.java10
3 files changed, 52 insertions, 14 deletions
diff --git a/jack-tests/src/com/android/jack/test/toolchain/JackApiV01Toolchain.java b/jack-tests/src/com/android/jack/test/toolchain/JackApiV01Toolchain.java
index 83efb1e9..2d7f6f2b 100644
--- a/jack-tests/src/com/android/jack/test/toolchain/JackApiV01Toolchain.java
+++ b/jack-tests/src/com/android/jack/test/toolchain/JackApiV01Toolchain.java
@@ -19,14 +19,18 @@ package com.android.jack.test.toolchain;
import com.google.common.collect.Lists;
import com.android.jack.Options;
+import com.android.jack.api.v01.AbortException;
import com.android.jack.api.v01.Api01Config;
import com.android.jack.api.v01.ConfigurationException;
+import com.android.jack.api.v01.DebugInfoLevel;
+import com.android.jack.api.v01.ReporterKind;
import com.android.jack.api.v01.VerbosityLevel;
import com.android.jack.shrob.spec.Flags;
import com.android.jack.test.TestConfigurationException;
import com.android.sched.vfs.Container;
import java.io.File;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -51,7 +55,7 @@ public class JackApiV01Toolchain extends JackApiToolchainBase {
throws Exception {
srcToCommon(sources);
setOutputDex(out);
- apiV01Config.getTask().run();
+ run();
}
@Override
@@ -59,21 +63,21 @@ public class JackApiV01Toolchain extends JackApiToolchainBase {
throws Exception {
srcToCommon(sources);
setOutputJack(out);
- apiV01Config.getTask().run();
+ run();
}
@Override
public void libToExe(@Nonnull File[] in, @Nonnull File out, boolean zipFile) throws Exception {
libToCommon(in);
setOutputDex(out);
- apiV01Config.getTask().run();
+ run();
}
@Override
public void libToLib(@Nonnull File[] in, @Nonnull File out, boolean zipFiles) throws Exception {
libToCommon(in);
setOutputJack(out);
- apiV01Config.getTask().run();
+ run();
}
@Override
@@ -119,7 +123,7 @@ public class JackApiV01Toolchain extends JackApiToolchainBase {
@Nonnull
public JackApiV01Toolchain setWithDebugInfos(boolean withDebugInfos) {
try {
- apiV01Config.setEmitDebug(withDebugInfos);
+ apiV01Config.setDebugInfoLevel(DebugInfoLevel.FULL);
return this;
} catch (ConfigurationException e) {
throw new TestConfigurationException(e);
@@ -144,6 +148,43 @@ public class JackApiV01Toolchain extends JackApiToolchainBase {
}
}
+ @Override
+ @Nonnull
+ public final Toolchain setErrorStream(@Nonnull OutputStream errorStream) {
+ super.setErrorStream(errorStream);
+ try {
+ apiV01Config.setReporter(ReporterKind.DEFAULT, errorStream);
+ } catch (ConfigurationException e) {
+ throw new TestConfigurationException(e);
+ }
+ return this;
+ }
+
+ private void run() throws Exception {
+ try {
+ System.setOut(outRedirectStream);
+ System.setErr(errRedirectStream);
+ apiV01Config.getTask().run();
+ } catch (ConfigurationException e) {
+ Throwable t1 = e.getCause();
+ if (t1 instanceof Exception) {
+ throw (Exception) t1;
+ } else {
+ throw new AssertionError();
+ }
+ } catch (AbortException e1) {
+ Throwable t1 = e1.getCause();
+ if (t1 instanceof Exception) {
+ throw (Exception) t1;
+ } else {
+ throw new AssertionError();
+ }
+ } finally {
+ System.setOut(stdOut);
+ System.setOut(stdErr);
+ }
+ }
+
private void srcToCommon(@Nonnull File... sources) throws Exception {
apiV01Config.setClasspath(classpath);
apiV01Config.setImportedJackLibraryFiles(staticLibs);
diff --git a/jack-tests/tests/com/android/jack/multidex/MultiDexOverflowTests.java b/jack-tests/tests/com/android/jack/multidex/MultiDexOverflowTests.java
index 58fa82c5..6f67a945 100644
--- a/jack-tests/tests/com/android/jack/multidex/MultiDexOverflowTests.java
+++ b/jack-tests/tests/com/android/jack/multidex/MultiDexOverflowTests.java
@@ -119,9 +119,8 @@ public class MultiDexOverflowTests {
.addToClasspath(annotations)
.srcToExe(outFolder, /* zipFile = */ false, srcFolder);
Assert.fail();
- } catch (ProcessException e) {
- Assert.assertTrue(e.getCause() instanceof JackAbortException);
- Throwable contextException = e.getCause().getCause();
+ } catch (JackAbortException e) {
+ Throwable contextException = e.getCause();
Assert.assertTrue(contextException instanceof DexWritingException);
Assert.assertTrue(contextException.getCause() instanceof MainDexOverflowException);
Assert.assertTrue(contextException.getCause().getCause() instanceof FieldIdOverflowException);
diff --git a/jack-tests/tests/com/android/jack/tools/merger/test011/MergerTest011.java b/jack-tests/tests/com/android/jack/tools/merger/test011/MergerTest011.java
index 23932846..351b5906 100644
--- a/jack-tests/tests/com/android/jack/tools/merger/test011/MergerTest011.java
+++ b/jack-tests/tests/com/android/jack/tools/merger/test011/MergerTest011.java
@@ -75,9 +75,8 @@ public class MergerTest011 extends MergerTestTools {
try {
buildOneDexPerType(srcFolder, /* withDebug = */false, /* out = */ null, err);
Assert.fail();
- } catch (ProcessException e) {
- Assert.assertTrue(e.getCause() instanceof JackAbortException);
- Throwable contextException = e.getCause().getCause();
+ } catch (JackAbortException e) {
+ Throwable contextException = e.getCause();
Assert.assertTrue(contextException instanceof DexWritingException);
Assert.assertTrue(contextException.getCause() instanceof SingleDexOverflowException);
Assert.assertTrue(contextException.getCause().getCause() instanceof MethodIdOverflowException);
@@ -99,9 +98,8 @@ public class MergerTest011 extends MergerTestTools {
try {
buildOneDexPerType(srcFolder, /* withDebug = */false, /* out = */ null, err);
Assert.fail();
- } catch (ProcessException e) {
- Assert.assertTrue(e.getCause() instanceof JackAbortException);
- Throwable contextException = e.getCause().getCause();
+ } catch (JackAbortException e) {
+ Throwable contextException = e.getCause();
Assert.assertTrue(contextException instanceof DexWritingException);
Assert.assertTrue(contextException.getCause() instanceof SingleDexOverflowException);
Assert.assertTrue(contextException.getCause().getCause() instanceof FieldIdOverflowException);