Migrate some legacy tests using dex-vm property
Bug: b/167145686
Change-Id: Ic581de4ef5fb45e78c709f5e272b2e233e9dee7b
diff --git a/src/test/java/com/android/tools/r8/classmerging/vertical/VerticalClassMergerTest.java b/src/test/java/com/android/tools/r8/classmerging/vertical/VerticalClassMergerTest.java
index b6c66b6..9826428 100644
--- a/src/test/java/com/android/tools/r8/classmerging/vertical/VerticalClassMergerTest.java
+++ b/src/test/java/com/android/tools/r8/classmerging/vertical/VerticalClassMergerTest.java
@@ -800,10 +800,10 @@
"In referencedMethod on SuperClassWithReferencedMethod",
"SuperClassWithReferencedMethod.referencedMethod()");
- testForD8()
+ testForD8(parameters.getBackend())
.addProgramFiles(programFiles)
.addProgramDexFileData(smaliBuilder.compile())
- .run(main)
+ .run(parameters.getRuntime(), main)
.assertSuccessWithOutput(expectedOutput);
testForR8(parameters.getBackend())
@@ -813,7 +813,7 @@
.addKeepRules("-keep class *")
.addProgramFiles(programFiles)
.addProgramDexFileData(smaliBuilder.compile())
- .run(main)
+ .run(parameters.getRuntime(), main)
.assertSuccessWithOutput(expectedOutput);
}
@@ -1217,7 +1217,7 @@
String d8Result =
testForD8()
.addProgramResourceProviders(input.getProgramResourceProviders())
- .run(main)
+ .run(parameters.getRuntime(), main)
.assertSuccess()
.getStdOut();
diff --git a/src/test/java/com/android/tools/r8/debug/BlockReorderingTest.java b/src/test/java/com/android/tools/r8/debug/BlockReorderingTest.java
index cee9b2a..aab70be 100644
--- a/src/test/java/com/android/tools/r8/debug/BlockReorderingTest.java
+++ b/src/test/java/com/android/tools/r8/debug/BlockReorderingTest.java
@@ -3,43 +3,53 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.debug;
-import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.CompilationFailedException;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
import com.android.tools.r8.ToolHelper.DexVm.Version;
-import java.util.Collections;
+import com.android.tools.r8.utils.AndroidApiLevel;
import org.junit.Assume;
-import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
-/**
- * Test single stepping behaviour across reordered blocks.
- */
+/** Test single stepping behaviour across reordered blocks. */
+@RunWith(Parameterized.class)
public class BlockReorderingTest extends DebugTestBase {
public static final String CLASS = "BlockReordering";
public static final String FILE = "BlockReordering.java";
- private static D8DebugTestConfig d8Config;
+ @Parameters(name = "{0}")
+ public static TestParametersCollection data() {
+ return TestParameters.builder().withDexRuntimes().withApiLevel(AndroidApiLevel.B).build();
+ }
- @BeforeClass
- public static void setup() {
- // Force inversion of all conditionals to reliably construct a regression test for incorrect
- // line information when reordering blocks.
- d8Config =
- new D8DebugTestConfig()
- .compileAndAdd(
- getStaticTemp(),
- Collections.singletonList(DEBUGGEE_JAR),
- options -> options.testing.invertConditionals = true);
+ @Parameter public TestParameters parameters;
+
+ public DebugTestConfig getDebugConfig() throws CompilationFailedException {
+ return testForD8()
+ .addProgramFiles(DEBUGGEE_JAR)
+ .setMinApi(parameters)
+ .addOptionsModification(options -> options.testing.invertConditionals = true)
+ .compile()
+ .debugConfig(parameters.getRuntime());
+ }
+
+ private void assumeValidTest() {
+ Assume.assumeFalse(
+ "Older runtimes incorrectly step out of function: b/67671565",
+ parameters.isDexRuntimeVersionOlderThanOrEqual(Version.V6_0_1));
}
@Test
public void testConditionalReturn() throws Throwable {
- Assume.assumeTrue(
- "Older runtimes incorrectly step out of function: b/67671565",
- ToolHelper.getDexVm().getVersion().isNewerThan(Version.V6_0_1));
+ assumeValidTest();
final String method = "conditionalReturn";
runDebugTest(
- d8Config,
+ getDebugConfig(),
CLASS,
breakpoint(CLASS, method),
run(),
@@ -57,12 +67,10 @@
@Test
public void testInvertConditionalReturn() throws Throwable {
- Assume.assumeTrue(
- "Older runtimes incorrectly step out of function: b/67671565",
- ToolHelper.getDexVm().getVersion().isNewerThan(Version.V6_0_1));
+ assumeValidTest();
final String method = "invertConditionalReturn";
runDebugTest(
- d8Config,
+ getDebugConfig(),
CLASS,
breakpoint(CLASS, method),
run(),
@@ -80,12 +88,10 @@
@Test
public void testFallthroughReturn() throws Throwable {
- Assume.assumeTrue(
- "Older runtimes incorrectly step out of function: b/67671565",
- ToolHelper.getDexVm().getVersion().isNewerThan(Version.V6_0_1));
+ assumeValidTest();
final String method = "fallthroughReturn";
runDebugTest(
- d8Config,
+ getDebugConfig(),
CLASS,
breakpoint(CLASS, method),
run(),
diff --git a/src/test/java/com/android/tools/r8/naming/KotlinIntrinsicsIdentifierTest.java b/src/test/java/com/android/tools/r8/naming/KotlinIntrinsicsIdentifierTest.java
index 63cacfc..1191b8a 100644
--- a/src/test/java/com/android/tools/r8/naming/KotlinIntrinsicsIdentifierTest.java
+++ b/src/test/java/com/android/tools/r8/naming/KotlinIntrinsicsIdentifierTest.java
@@ -175,7 +175,7 @@
.compile()
.assertAllWarningMessagesMatch(
equalTo("Resource 'META-INF/MANIFEST.MF' already exists."))
- .run(mainClassName);
+ .run(testParameters.getRuntime(), mainClassName);
CodeInspector codeInspector = result.inspector();
MethodSubject main = codeInspector.clazz(testMain.getClassName()).mainMethod();