Merge "Restrict max heap size for jctf tests to be aligned with build bots"
diff --git a/src/test/java/com/android/tools/r8/JctfTestSpecifications.java b/src/test/java/com/android/tools/r8/JctfTestSpecifications.java
index 937a46a..d8d983f 100644
--- a/src/test/java/com/android/tools/r8/JctfTestSpecifications.java
+++ b/src/test/java/com/android/tools/r8/JctfTestSpecifications.java
@@ -635,8 +635,7 @@
                       Runtime.ART_DEFAULT,
                       Runtime.ART_V7_0_0,
                       Runtime.ART_V6_0_1,
-                      Runtime.ART_V5_1_1,
-                      Runtime.JAVA)))
+                      Runtime.ART_V5_1_1)))
           .put(
               "lang.ref.SoftReference.isEnqueued.SoftReference_isEnqueued_A01",
               match(
@@ -644,9 +643,8 @@
                       Runtime.ART_DEFAULT,
                       Runtime.ART_V7_0_0,
                       Runtime.ART_V6_0_1,
-                      Runtime.ART_V5_1_1,
-                      Runtime.JAVA)))
-          .put("lang.ref.SoftReference.get.SoftReference_get_A01", any())
+                      Runtime.ART_V5_1_1)))
+          .put("lang.ref.SoftReference.get.SoftReference_get_A01", anyDexVm())
           .put("lang.ref.SoftReference.clear.SoftReference_clear_A01", cf())
           .put(
               "lang.ref.ReferenceQueue.poll.ReferenceQueue_poll_A01",
@@ -657,12 +655,11 @@
                       Runtime.ART_V8_1_0,
                       Runtime.ART_V7_0_0,
                       Runtime.ART_V6_0_1,
-                      Runtime.ART_V5_1_1,
-                      Runtime.JAVA)))
+                      Runtime.ART_V5_1_1)))
           .put(
               "lang.StackTraceElement.serialization.StackTraceElement_serialization_A01",
               anyDexVm())
-          .put("lang.ref.WeakReference.get.WeakReference_get_A01", any())
+          .put("lang.ref.WeakReference.get.WeakReference_get_A01", anyDexVm())
           .put(
               "lang.StackTraceElement.toString.StackTraceElement_toString_A01",
               match(runtimes(Runtime.ART_DEFAULT, Runtime.ART_V9_0_0, Runtime.ART_V8_1_0)))
@@ -1687,7 +1684,6 @@
           .put("lang.RuntimePermission.Class.RuntimePermission_class_A13", cf())
           .put("lang.Thread.stopLjava_lang_Throwable.Thread_stop_A01", cf())
           .put("lang.Runtime.addShutdownHookLjava_lang_Thread.Runtime_addShutdownHook_A02", cf())
-          .put("lang.ref.WeakReference.isEnqueued.WeakReference_isEnqueued_A01", cf())
           .put("lang.ThreadGroup.destroy.ThreadGroup_destroy_A04", cf())
           .put("lang.ThreadGroup.setMaxPriorityI.ThreadGroup_setMaxPriority_A02", cf())
           .put(
diff --git a/src/test/java/com/android/tools/r8/R8RunArtTestsTest.java b/src/test/java/com/android/tools/r8/R8RunArtTestsTest.java
index 2a4977d..0634d6f 100644
--- a/src/test/java/com/android/tools/r8/R8RunArtTestsTest.java
+++ b/src/test/java/com/android/tools/r8/R8RunArtTestsTest.java
@@ -1988,7 +1988,15 @@
       expectException(AssertionError.class);
     }
 
-    ProcessResult result = ToolHelper.runJava(resultDir.toPath(), JUNIT_TEST_RUNNER, fullClassName);
+    // Some tests rely on an OutOfMemoryError being thrown (fx MemoryHog.getBigArray()). To ensure
+    // compatible test results locally and externally, we need to synchronize the max heap size when
+    // running the test.
+    ProcessResult result =
+        ToolHelper.runJava(
+            resultDir.toPath(),
+            "-Xmx" + ToolHelper.BOT_MAX_HEAP_SIZE,
+            JUNIT_TEST_RUNNER,
+            fullClassName);
 
     if (result.exitCode != 0) {
       throw new AssertionError(
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index 95fd26d..69c710d 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -111,6 +111,8 @@
   private static final String RETRACE6_0_1 = "third_party/proguard/proguard6.0.1/bin/retrace";
   private static final String RETRACE = RETRACE6_0_1;
 
+  public static final long BOT_MAX_HEAP_SIZE = 7908360192L;
+
   public static final Path R8_JAR = Paths.get(LIBS_DIR, "r8.jar");
   public static final Path R8_WITH_RELOCATED_DEPS_JAR =
       Paths.get(LIBS_DIR, "r8_with_relocated_deps.jar");