Rename new testing state and its flags.

Two flags control the use of testing state:

  --with-testing-state

    Enables the use of state. If state exists testing continues with
    either the failed tests or if no tests failed, with the remaining
    tests.

  --reset-testing-state

    Implies the use of --with-testing-state, but will first clear any
    existing state, thus always resulting in a new/clean test run.

The state is now stored in a directory based on the git branch
name. This CL also fixes a potential double writing issue for the
stdout/err files.

Bug: 186607794
Change-Id: Ifd3d7f3410104c5e6047d17900e7d87356cc9a89
diff --git a/tools/test.py b/tools/test.py
index 685cbf2..157bd28 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -171,8 +171,12 @@
       help='Print the execution time of the slowest tests..',
       default=False, action='store_true')
   result.add_option(
-      '--testing-report',
-      help='Use the custom testing report output format',
+      '--with-testing-state',
+      help='Run/resume tests using testing state.',
+      default=False, action='store_true')
+  result.add_option(
+      '--reset-testing-state',
+      help='Clean the testing state and rerun tests (implies --with-testing-state).',
       default=False, action='store_true')
   result.add_option(
       '--stacktrace',
@@ -313,8 +317,11 @@
     gradle_args.append('-Pdesugar_jdk_json_dir=' + desugar_jdk_json_dir)
   if desugar_jdk_libs:
     gradle_args.append('-Pdesugar_jdk_libs=' + desugar_jdk_libs)
-  if options.testing_report:
-    gradle_args.append('-Ptesting-report')
+  if options.reset_testing_state:
+    gradle_args.append('-Ptesting-state')
+    gradle_args.append('-Preset-testing-state')
+  elif options.with_testing_state:
+    gradle_args.append('-Ptesting-state')
 
   # Build an R8 with dependencies for bootstrapping tests before adding test sources.
   gradle_args.append('r8WithDeps')