Add a --slow_tests/--slow-tests flag to test.py

Change-Id: I131ca7bd1c7ae077021c5880e1f00b9eb9ea3141
diff --git a/build.gradle b/build.gradle
index 9f8ba22..ebe244a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1841,6 +1841,10 @@
         systemProperty 'runtimes', project.property('runtimes')
     }
 
+    if (project.hasProperty('slow_tests')) {
+        systemProperty 'slow_tests', project.property('slow_tests')
+    }
+
     if (project.hasProperty('one_line_per_test')) {
         beforeTest { desc ->
             println "Start executing test ${desc.name} [${desc.className}]"
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index b0f00db..0f5e50c 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -149,6 +149,10 @@
   public static final Path R8LIB_EXCLUDE_DEPS_JAR = Paths.get(LIBS_DIR, "r8lib-exclude-deps.jar");
   public static final Path DEPS_NOT_RELOCATED = Paths.get(LIBS_DIR, "deps-not-relocated.jar");
 
+  public static boolean shouldRunSlowTests() {
+    return System.getProperty("slow_tests", "0").equals("1");
+  }
+
   public static boolean verifyValidOutputMode(Backend backend, OutputMode outputMode) {
     return (backend == Backend.CF && outputMode == OutputMode.ClassFile)
         || (backend == Backend.DEX && outputMode != OutputMode.ClassFile);
diff --git a/tools/test.py b/tools/test.py
index be271f2..6e7bfd9 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -58,6 +58,9 @@
   result.add_option('--all-tests', '--all_tests',
       help='Run tests in all configurations.',
       default=False, action='store_true')
+  result.add_option('--slow-tests', '--slow_tests',
+      help='Also run slow tests.',
+      default=False, action='store_true')
   result.add_option('-v', '--verbose',
       help='Print test stdout to, well, stdout.',
       default=False, action='store_true')
@@ -158,6 +161,8 @@
     gradle_args.append('-Ponly_internal')
   if options.all_tests:
     gradle_args.append('-Pall_tests')
+  if options.slow_tests:
+    gradle_args.append('-Pslow_tests=1')
   if options.tool:
     gradle_args.append('-Ptool=%s' % options.tool)
   if options.one_line_per_test: