Add debug test stub for testing debug info when inlining.
Bug:
Change-Id: I94830f8490b846d5929d5f3b266e90ee5d56e6f9
diff --git a/src/test/debugTestResources/Inlining1.java b/src/test/debugTestResources/Inlining1.java
new file mode 100644
index 0000000..e9fa2cb
--- /dev/null
+++ b/src/test/debugTestResources/Inlining1.java
@@ -0,0 +1,28 @@
+// Copyright (c) 2017, 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.
+
+public class Inlining1 {
+ private static void inlineThisFromSameFile() {
+ System.out.println("inlineThisFromSameFile");
+ }
+
+ private static void sameFileMultilevelInliningLevel2() {
+ System.out.println("sameFileMultilevelInliningLevel2");
+ }
+
+ private static void sameFileMultilevelInliningLevel1() {
+ sameFileMultilevelInliningLevel2();
+ }
+
+ public static void main(String[] args) {
+ inlineThisFromSameFile();
+ inlineThisFromSameFile();
+ Inlining2.inlineThisFromAnotherFile();
+ Inlining2.inlineThisFromAnotherFile();
+ sameFileMultilevelInliningLevel1();
+ sameFileMultilevelInliningLevel1();
+ Inlining2.differentFileMultilevelInliningLevel1();
+ Inlining2.differentFileMultilevelInliningLevel1();
+ }
+}
diff --git a/src/test/debugTestResources/Inlining2.java b/src/test/debugTestResources/Inlining2.java
new file mode 100644
index 0000000..38f854c
--- /dev/null
+++ b/src/test/debugTestResources/Inlining2.java
@@ -0,0 +1,13 @@
+// Copyright (c) 2017, 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.
+
+public class Inlining2 {
+ public static void inlineThisFromAnotherFile() {
+ System.out.println("inlineThisFromAnotherFile");
+ }
+
+ public static void differentFileMultilevelInliningLevel1() {
+ Inlining3.differentFileMultilevelInliningLevel2();
+ }
+}
diff --git a/src/test/debugTestResources/Inlining3.java b/src/test/debugTestResources/Inlining3.java
new file mode 100644
index 0000000..dcb965e
--- /dev/null
+++ b/src/test/debugTestResources/Inlining3.java
@@ -0,0 +1,9 @@
+// Copyright (c) 2017, 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.
+
+public class Inlining3 {
+ public static void differentFileMultilevelInliningLevel2() {
+ System.out.println("differentFileMultilevelInliningLevel2");
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/debug/DebugInfoWhenInliningTest.java b/src/test/java/com/android/tools/r8/debug/DebugInfoWhenInliningTest.java
new file mode 100644
index 0000000..d8649c7
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/debug/DebugInfoWhenInliningTest.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2017, 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.CompilationMode;
+import java.util.Collections;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Tests source file and line numbers on inlined methods. */
+public class DebugInfoWhenInliningTest extends DebugTestBase {
+
+ public static final String SOURCE_FILE = "Inlining1.java";
+ private static DebuggeePath debuggeePath;
+
+ @BeforeClass
+ public static void initDebuggeePath() throws Exception {
+ debuggeePath =
+ DebuggeePath.makeDex(
+ compileToDexViaR8(
+ null,
+ null,
+ DEBUGGEE_JAR,
+ Collections.<String>emptyList(),
+ true,
+ CompilationMode.RELEASE));
+ }
+
+ @Test
+ public void testEachLine() throws Throwable {
+ final String className = "Inlining1";
+ final String methodName = "main";
+ final String signature = "([Ljava/lang/String;)V";
+ runDebugTest(
+ debuggeePath,
+ className,
+ breakpoint(className, methodName, signature),
+ run(),
+ checkMethod(className, methodName, signature),
+ // TODO(tamaskenez) to be continued as the feature is implemented in class Inliner
+ run());
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
index f6e680a..740d4e3 100644
--- a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
+++ b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
@@ -243,7 +243,8 @@
Consumer<ProguardConfiguration.Builder> pgConsumer,
Path jarToCompile,
List<String> proguardConfigurations,
- boolean writeProguardMap)
+ boolean writeProguardMap,
+ CompilationMode compilationMode)
throws IOException, CompilationException, ExecutionException, ProguardRuleParserException {
int minSdk = ToolHelper.getMinApiLevelForDexVm(ToolHelper.getDexVm());
assert jarToCompile.toFile().exists();
@@ -254,7 +255,8 @@
.setOutputPath(dexOutputDir)
.setMinApiLevel(minSdk)
.setMode(CompilationMode.DEBUG)
- .addLibraryFiles(Paths.get(ToolHelper.getAndroidJar(minSdk)));
+ .addLibraryFiles(Paths.get(ToolHelper.getAndroidJar(minSdk)))
+ .setMode(compilationMode);
if (writeProguardMap) {
builder.setProguardMapOutput(dexOutputDir.resolve(PROGUARD_MAP_FILENAME));
}
diff --git a/src/test/java/com/android/tools/r8/debug/MinificationTest.java b/src/test/java/com/android/tools/r8/debug/MinificationTest.java
index 9c0702f..1419c7f 100644
--- a/src/test/java/com/android/tools/r8/debug/MinificationTest.java
+++ b/src/test/java/com/android/tools/r8/debug/MinificationTest.java
@@ -4,6 +4,7 @@
package com.android.tools.r8.debug;
import com.android.tools.r8.CompilationException;
+import com.android.tools.r8.CompilationMode;
import com.android.tools.r8.TestBase.MinifyMode;
import com.android.tools.r8.shaking.ProguardRuleParserException;
import com.google.common.collect.ImmutableList;
@@ -18,7 +19,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-/** Tests local variable information. */
+/** Tests renaming of class and method names and corresponding proguard map output. */
@RunWith(Parameterized.class)
public class MinificationTest extends DebugTestBase {
@@ -70,7 +71,12 @@
}
path =
compileToDexViaR8(
- null, null, DEBUGGEE_JAR, proguardConfigurations, config.writeProguardMap);
+ null,
+ null,
+ DEBUGGEE_JAR,
+ proguardConfigurations,
+ config.writeProguardMap,
+ CompilationMode.DEBUG);
debuggeePathMap.put(config, path);
}
return DebuggeePath.makeDex(path);
diff --git a/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java b/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
index 046a14b..75892cb 100644
--- a/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
+++ b/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
@@ -4,8 +4,8 @@
package com.android.tools.r8.naming;
import com.android.tools.r8.CompilationException;
+import com.android.tools.r8.CompilationMode;
import com.android.tools.r8.debug.DebugTestBase;
-import com.android.tools.r8.shaking.ProguardKeepRule;
import com.android.tools.r8.shaking.ProguardRuleParserException;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
@@ -36,7 +36,8 @@
},
DEBUGGEE_JAR,
Collections.<String>emptyList(),
- false));
+ false,
+ CompilationMode.DEBUG));
}
/**