Add --testing-state-name flag to test.py

This allows manually setting the test state name. This can be used to
rerun state gathered on another branch or to explicitly set the name,
e.g., when invoking tests on a worktree in detached mode (thus avoiding
the state name to be HEAD).

Change-Id: Ia963db386fedb749f7fbc1e441535d60e440ec7c
diff --git a/tools/test.py b/tools/test.py
index 157bd28..9c35352 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -171,6 +171,10 @@
       help='Print the execution time of the slowest tests..',
       default=False, action='store_true')
   result.add_option(
+      '--testing-state-name',
+      help='Set an explict name for the testing state '
+          '(used in conjunction with --with/reset-testing-state).')
+  result.add_option(
       '--with-testing-state',
       help='Run/resume tests using testing state.',
       default=False, action='store_true')
@@ -322,6 +326,8 @@
     gradle_args.append('-Preset-testing-state')
   elif options.with_testing_state:
     gradle_args.append('-Ptesting-state')
+  if options.testing_state_name:
+    gradle_args.append('-Ptesting-state-name=' + options.testing_state_name)
 
   # Build an R8 with dependencies for bootstrapping tests before adding test sources.
   gradle_args.append('r8WithDeps')