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/build.gradle b/build.gradle
index 3acdbf2..4a8dd81 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2049,7 +2049,9 @@
// Hide all test events from the console, they are written to the report.
task.testLogging { events = [] }
- def branch = getGitBranchName()
+ def branch = project.hasProperty('testing-state-name')
+ ? project.getProperty('testing-state-name')
+ : getGitBranchName()
def reportDir = file("${buildDir}/test-state/${branch}")
def index = reportDir.toPath().resolve("index.html").toFile()
def resetState = project.hasProperty('reset-testing-state')
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')