Merge "Return 0 as return_code explicitly."
diff --git a/build.gradle b/build.gradle
index 51fcf4e..993e894 100644
--- a/build.gradle
+++ b/build.gradle
@@ -678,13 +678,33 @@
         classpath = sourceSets.examples.compileClasspath
         sourceCompatibility = JavaVersion.VERSION_1_7
         targetCompatibility = JavaVersion.VERSION_1_7
-        options.compilerArgs = ["-Xlint:none"]
+        options.compilerArgs = ["-g:source,lines", "-Xlint:none"]
+    }
+    task "compile_examples_debuginfo_all"(type: JavaCompile, dependsOn: "generateExamplesProto") {
+        source examplesDir, protoSourceDir
+        include "**/*.java"
+        destinationDir = file("build/test/examples/classes_debuginfo_all")
+        classpath = sourceSets.examples.compileClasspath
+        sourceCompatibility = JavaVersion.VERSION_1_7
+        targetCompatibility = JavaVersion.VERSION_1_7
+        options.compilerArgs = ["-g", "-Xlint:none"]
+    }
+    task "compile_examples_debuginfo_none"(type: JavaCompile, dependsOn: "generateExamplesProto") {
+        source examplesDir, protoSourceDir
+        include "**/*.java"
+        destinationDir = file("build/test/examples/classes_debuginfo_none")
+        classpath = sourceSets.examples.compileClasspath
+        sourceCompatibility = JavaVersion.VERSION_1_7
+        targetCompatibility = JavaVersion.VERSION_1_7
+        options.compilerArgs = ["-g:none", "-Xlint:none"]
     }
     examplesDir.eachDir { dir ->
         def name = dir.getName();
         def exampleOutputDir = file("build/test/examples");
         def jarName = "${name}.jar"
         dependsOn "jar_example_${name}"
+        dependsOn "jar_example_${name}_debuginfo_all"
+        dependsOn "jar_example_${name}_debuginfo_none"
         dependsOn "extractExamplesRuntime"
         def runtimeDependencies = copySpec { }
         if (!fileTree(dir: dir, include: '**/*.proto').empty) {
@@ -727,15 +747,40 @@
                 }
                 outputs.file proguardJarPath
             }
+            // TODO: Consider performing distinct proguard compilations.
+            task "jar_example_${name}_debuginfo_all"(type: Copy, dependsOn: "jar_example_${name}") {
+                from "${exampleOutputDir}/${name}.jar"
+                into "${exampleOutputDir}/${name}_debuginfo_all.jar"
+            }
+            task "jar_example_${name}_debuginfo_none"(type: Copy, dependsOn: "jar_example_${name}") {
+                from "${exampleOutputDir}/${name}.jar"
+                into "${exampleOutputDir}/${name}_debuginfo_none.jar"
+            }
         } else {
             task "jar_example_${name}"(type: Jar, dependsOn: "compile_examples") {
-                archiveName = jarName
+                archiveName = "${name}.jar"
                 destinationDir = exampleOutputDir
                 from "build/test/examples/classes"
                 include name + "/**/*.class"
                 with runtimeDependencies
                 includeEmptyDirs false
             }
+            task "jar_example_${name}_debuginfo_all"(type: Jar, dependsOn: "compile_examples_debuginfo_all") {
+                archiveName = "${name}_debuginfo_all.jar"
+                destinationDir = exampleOutputDir
+                from "build/test/examples/classes_debuginfo_all"
+                include name + "/**/*.class"
+                with runtimeDependencies
+                includeEmptyDirs false
+            }
+            task "jar_example_${name}_debuginfo_none"(type: Jar, dependsOn: "compile_examples_debuginfo_none") {
+                archiveName = "${name}_debuginfo_none.jar"
+                destinationDir = exampleOutputDir
+                from "build/test/examples/classes_debuginfo_none"
+                include name + "/**/*.class"
+                with runtimeDependencies
+                includeEmptyDirs false
+            }
         }
     }
 }
diff --git a/src/test/java/com/android/tools/r8/R8RunExamplesTest.java b/src/test/java/com/android/tools/r8/R8RunExamplesTest.java
index febff20..1676731 100644
--- a/src/test/java/com/android/tools/r8/R8RunExamplesTest.java
+++ b/src/test/java/com/android/tools/r8/R8RunExamplesTest.java
@@ -40,6 +40,10 @@
 @RunWith(Parameterized.class)
 public class R8RunExamplesTest {
 
+  enum Input {
+    DX, JAVAC, JAVAC_ALL, JAVAC_NONE
+  }
+
   private static final String EXAMPLE_DIR = ToolHelper.EXAMPLES_BUILD_DIR;
 
   // For local testing on a specific Art version(s) change this set. e.g. to
@@ -114,23 +118,32 @@
 
     List<String[]> fullTestList = new ArrayList<>(tests.length * 2);
     for (String test : tests) {
-      fullTestList.add(makeTest(DexTool.NONE, CompilerUnderTest.D8, CompilationMode.DEBUG, test));
-      fullTestList.add(makeTest(DexTool.NONE, CompilerUnderTest.R8, CompilationMode.RELEASE, test));
-      fullTestList.add(makeTest(DexTool.DX, CompilerUnderTest.R8, CompilationMode.RELEASE, test));
+      fullTestList.add(makeTest(Input.JAVAC, CompilerUnderTest.D8, CompilationMode.DEBUG, test));
+      fullTestList.add(makeTest(Input.JAVAC_ALL, CompilerUnderTest.D8, CompilationMode.DEBUG,
+          test));
+      fullTestList.add(makeTest(Input.JAVAC_NONE, CompilerUnderTest.D8, CompilationMode.DEBUG,
+          test));
+      fullTestList.add(makeTest(Input.JAVAC_ALL, CompilerUnderTest.D8, CompilationMode.RELEASE,
+          test));
+      fullTestList.add(makeTest(Input.JAVAC_ALL, CompilerUnderTest.R8, CompilationMode.RELEASE,
+          test));
+      fullTestList.add(makeTest(Input.JAVAC_ALL, CompilerUnderTest.R8, CompilationMode.DEBUG,
+          test));
+      fullTestList.add(makeTest(Input.DX, CompilerUnderTest.R8, CompilationMode.RELEASE, test));
     }
     return fullTestList;
   }
 
   private static String[] makeTest(
-      DexTool tool, CompilerUnderTest compiler, CompilationMode mode, String clazz) {
+      Input input, CompilerUnderTest compiler, CompilationMode mode, String clazz) {
     String pkg = clazz.substring(0, clazz.lastIndexOf('.'));
-    return new String[]{pkg, tool.name(), compiler.name(), mode.name(), clazz};
+    return new String[]{pkg, input.name(), compiler.name(), mode.name(), clazz};
   }
 
   @Rule
   public TemporaryFolder temp = ToolHelper.getTemporaryFolderForTest();
 
-  private final DexTool tool;
+  private final Input input;
   private final CompilerUnderTest compiler;
   private final CompilationMode mode;
   private final String pkg;
@@ -138,33 +151,44 @@
 
   public R8RunExamplesTest(
       String pkg,
-      String tool,
+      String input,
       String compiler,
       String mode,
       String mainClass) {
     this.pkg = pkg;
-    this.tool = DexTool.valueOf(tool);
+    this.input = Input.valueOf(input);
     this.compiler = CompilerUnderTest.valueOf(compiler);
     this.mode = CompilationMode.valueOf(mode);
     this.mainClass = mainClass;
   }
 
   private Path getInputFile() {
-    if (tool == DexTool.NONE) {
-      return getOriginalJarFile();
+    switch(input) {
+      case DX:
+        return getOriginalDexFile();
+      case JAVAC:
+        return getOriginalJarFile("");
+      case JAVAC_ALL:
+        return getOriginalJarFile("_debuginfo_all");
+      case JAVAC_NONE:
+        return getOriginalJarFile("_debuginfo_none");
+      default:
+        throw new Unreachable();
     }
-    assert tool == DexTool.DX;
-    return getOriginalDexFile();
   }
 
-  public Path getOriginalJarFile() {
-    return Paths.get(EXAMPLE_DIR, pkg + JAR_EXTENSION);
+  public Path getOriginalJarFile(String postFix) {
+    return Paths.get(EXAMPLE_DIR, pkg + postFix + JAR_EXTENSION);
   }
 
   private Path getOriginalDexFile() {
     return Paths.get(EXAMPLE_DIR, pkg, FileUtils.DEFAULT_DEX_FILENAME);
   }
 
+  private DexTool getTool() {
+    return input == Input.DX ? DexTool.DX : DexTool.NONE;
+  }
+
   @Rule
   public ExpectedException thrown = ExpectedException.none();
 
@@ -216,7 +240,7 @@
     }
 
     ToolHelper.ProcessResult javaResult =
-        ToolHelper.runJava(ImmutableList.of(getOriginalJarFile().toString()), mainClass);
+        ToolHelper.runJava(ImmutableList.of(getOriginalJarFile("").toString()), mainClass);
     if (javaResult.exitCode != 0) {
       fail("JVM failed for: " + mainClass);
     }
@@ -225,7 +249,7 @@
     // this explicit loop to get rid of repeated testing on the buildbots.
     for (DexVm version : artVersions) {
       TestCondition condition = failingRun.get(mainClass);
-      if (condition != null && condition.test(tool, compiler, version, mode)) {
+      if (condition != null && condition.test(getTool(), compiler, version, mode)) {
         thrown.expect(Throwable.class);
       } else {
         thrown = ExpectedException.none();
@@ -248,6 +272,6 @@
 
   private boolean shouldMatchJVMOutput(DexVm version) {
     TestCondition condition = outputNotIdenticalToJVMOutput.get(mainClass);
-    return condition == null || !condition.test(tool, compiler, version, mode);
+    return condition == null || !condition.test(getTool(), compiler, version, mode);
   }
 }