Disable MethodHandleTestRunner tests that fail on buildbot
Output stacktrace and Origin info when the tests fail (before skipping
them with JUnit Assume.assumeNoException()). This should allow
extracting a stacktrace from the buildbot to help investigate the
problem.
Also use an if-statement instead of Assume.assumeTrue() to skip DEX
tests on non-default Art VM buildbots.
Using Assume.assumeTrue(getDexVm() == ART_DEFAULT) leads to "SKIPPED"
in the buildbot logs, whereas "PASSED" would be expected.
Bug: 79725635
Change-Id: I77db5f4a9a1b1bd3cf3250d05eb5305f60cd38ac
diff --git a/src/test/java/com/android/tools/r8/cf/MethodHandleTestRunner.java b/src/test/java/com/android/tools/r8/cf/MethodHandleTestRunner.java
index df57902..e43ffd7 100644
--- a/src/test/java/com/android/tools/r8/cf/MethodHandleTestRunner.java
+++ b/src/test/java/com/android/tools/r8/cf/MethodHandleTestRunner.java
@@ -15,9 +15,12 @@
import com.android.tools.r8.ToolHelper;
import com.android.tools.r8.ToolHelper.DexVm;
import com.android.tools.r8.ToolHelper.ProcessResult;
+import com.android.tools.r8.errors.CompilationError;
import com.android.tools.r8.origin.Origin;
import com.android.tools.r8.utils.AndroidApiLevel;
+import com.android.tools.r8.utils.DefaultDiagnosticsHandler;
import com.android.tools.r8.utils.DescriptorUtils;
+import com.android.tools.r8.utils.Reporter;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
@@ -87,7 +90,10 @@
public void test() throws Exception {
runInput();
runCf();
- runDex();
+ // TODO(mathiasr): Once we include a P runtime, change this to "P and above".
+ if (ToolHelper.getDexVm() == DexVm.ART_DEFAULT && ToolHelper.artSupported()) {
+ runDex();
+ }
}
private final Class[] inputClasses = {
@@ -125,8 +131,6 @@
}
private void runDex() throws Exception {
- // TODO(mathiasr): Once we include a P runtime, change this to "P and above".
- Assume.assumeTrue(ToolHelper.getDexVm() == DexVm.ART_DEFAULT);
Path outDex = temp.getRoot().toPath().resolve("dex.zip");
build(new DexIndexedConsumer.ArchiveConsumer(outDex));
String expected = lookupType == LookupType.CONSTANT ? "pass" : "exception";
@@ -167,8 +171,21 @@
"}"),
Origin.unknown());
}
- ToolHelper.runR8(
- command.build(), options -> options.enableCfFrontend = frontend == Frontend.CF);
+ try {
+ ToolHelper.runR8(
+ command.build(), options -> options.enableCfFrontend = frontend == Frontend.CF);
+ } catch (CompilationError e) {
+ if (frontend == Frontend.CF && compilationMode == CompilationMode.DEBUG) {
+ // TODO(b/79725635): Investigate why these tests fail on the buildbot.
+ // Use a Reporter to extract origin info to standard error.
+ new Reporter(new DefaultDiagnosticsHandler()).error(e);
+ // Print the stack trace since this is not always printed by JUnit.
+ e.printStackTrace();
+ Assume.assumeNoException(
+ "TODO(b/79725635): Investigate why these tests fail on the buildbot.", e);
+ }
+ throw e;
+ }
}
private byte[] getClassAsBytes(Class<?> clazz) throws Exception {