Support Kotlin in continuous stepping tests
Allows to setup Kotlin test cases to make sure that a debugger is
able to step through a whole Kotlin program compiled with D8.
Change-Id: Id9b221f4cca348636a115580237ecc914126759a
diff --git a/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java b/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
index 1236866..d371243 100644
--- a/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
+++ b/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
@@ -12,24 +12,32 @@
public class ContinuousSteppingTest extends DebugTestBase {
- private static DebugTestConfig config;
+ private static DebugTestConfig javaD8Config;
+ private static DebugTestConfig kotlinD8Config;
@BeforeClass
public static void setup() {
- config = new D8DebugTestResourcesConfig(temp);
+ javaD8Config = new D8DebugTestResourcesConfig(temp);
+ kotlinD8Config = new KotlinD8Config(temp);
}
@Test
public void testArithmetic() throws Throwable {
- runContinuousTest("Arithmetic");
+ runContinuousTest("Arithmetic", javaD8Config);
}
@Test
public void testLocals() throws Throwable {
- runContinuousTest("Locals");
+ runContinuousTest("Locals", javaD8Config);
}
- private void runContinuousTest(String debuggeeClassName) throws Throwable {
+ @Test
+ public void testKotlinInline() throws Throwable {
+ runContinuousTest("KotlinInline", kotlinD8Config);
+ }
+
+ private void runContinuousTest(String debuggeeClassName, DebugTestConfig config)
+ throws Throwable {
runDebugTest(
config,
debuggeeClassName,
diff --git a/src/test/java/com/android/tools/r8/debug/KotlinD8Config.java b/src/test/java/com/android/tools/r8/debug/KotlinD8Config.java
new file mode 100644
index 0000000..fa5f5ca
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/debug/KotlinD8Config.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.debug;
+
+import com.android.tools.r8.OutputMode;
+import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.utils.AndroidApp;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import org.junit.rules.TemporaryFolder;
+
+/**
+ * Shared test configuration for D8 compiled resources from the "debugTestResourcesKotlin" target.
+ */
+class KotlinD8Config extends D8DebugTestConfig {
+
+ private static final Path DEBUGGEE_KOTLIN_JAR =
+ Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources_kotlin.jar");
+
+ private static AndroidApp compiledResources = null;
+
+ private static synchronized AndroidApp getCompiledResources() throws Throwable {
+ if (compiledResources == null) {
+ compiledResources =
+ D8DebugTestConfig.d8Compile(
+ Collections.singletonList(DEBUGGEE_KOTLIN_JAR), null);
+ }
+ return compiledResources;
+ }
+
+ public KotlinD8Config(TemporaryFolder temp) {
+ super();
+ try {
+ Path out = temp.newFolder().toPath().resolve("d8_debug_test_resources_kotlin.jar");
+ getCompiledResources().write(out, OutputMode.DexIndexed);
+ addPaths(out);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java b/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
index 845a450..5ddd98c 100644
--- a/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
+++ b/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
@@ -4,51 +4,20 @@
package com.android.tools.r8.debug;
-import com.android.tools.r8.OutputMode;
import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.utils.AndroidApp;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.apache.harmony.jpda.tests.framework.jdwp.Frame.Variable;
import org.apache.harmony.jpda.tests.framework.jdwp.Location;
import org.junit.BeforeClass;
-import org.junit.rules.TemporaryFolder;
/**
* A specialization for Kotlin-based tests which provides extra commands.
*/
public abstract class KotlinDebugTestBase extends DebugTestBase {
- private static final Path DEBUGGEE_KOTLIN_JAR =
- Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources_kotlin.jar");
-
- protected static class KotlinD8Config extends D8DebugTestConfig {
-
- private static AndroidApp compiledResources = null;
-
- private static synchronized AndroidApp getCompiledResources() throws Throwable {
- if (compiledResources == null) {
- compiledResources =
- D8DebugTestConfig.d8Compile(Collections.singletonList(DEBUGGEE_KOTLIN_JAR), null);
- }
- return compiledResources;
- }
-
- public KotlinD8Config(TemporaryFolder temp) {
- super();
- try {
- Path out = temp.newFolder().toPath().resolve("d8_debug_test_resources_kotlin.jar");
- getCompiledResources().write(out, OutputMode.DexIndexed);
- addPaths(out);
- } catch (Throwable e) {
- throw new RuntimeException(e);
- }
- }
- }
-
private static KotlinD8Config d8Config;
@BeforeClass