Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(889)

Unified Diff: build/android/test_runner.py

Issue 2752493002: [android] Add support for passing command-line flags directly. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build/android/test_runner.py
diff --git a/build/android/test_runner.py b/build/android/test_runner.py
index 952fca3fd650091b513917bb5e20a7c0d37f24e1..c534a48260b7795ae396a79064f01a61f1333c6c 100755
--- a/build/android/test_runner.py
+++ b/build/android/test_runner.py
@@ -42,7 +42,7 @@ _DEVIL_STATIC_CONFIG_FILE = os.path.abspath(os.path.join(
host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'devil_config.json'))
-def AddTestLauncherArgs(parser):
+def AddTestLauncherOptions(parser):
"""Adds arguments mirroring //base/test/launcher.
Args:
@@ -67,6 +67,20 @@ def AddTestLauncherArgs(parser):
return parser
+def AddCommandLineOptions(parser):
+ """Adds arguments to support passing command-line flags to the device."""
+ parser.add_argument(
+ '--device-flags-file',
+ type=os.path.realpath,
+ help='The relative filepath to a file containing '
+ 'command-line flags to set on the device')
+ parser.add_argument(
+ '-a', '--test-arguments',
+ dest='test_arguments', default='',
+ help='DEPRECATED. Pass such flags directly.')
shenghuazhang 2017/03/14 05:45:05 This version enables deprecated argument '--test-a
jbudorick 2017/03/15 18:28:00 hrm, good point. As this is deprecated, though, I'
+ parser.set_defaults(allow_unknown=True)
+
+
def AddTracingOptions(parser):
# TODO(shenghuazhang): Move this into AddCommonOptions once it's supported
# for all test types.
@@ -152,7 +166,7 @@ def AddCommonOptions(parser):
dest='verbose_count', default=0, action='count',
help='Verbose level (multiple times for more)')
- AddTestLauncherArgs(parser)
+ AddTestLauncherOptions(parser)
def ProcessCommonOptions(args):
@@ -282,10 +296,6 @@ def AddGTestOptions(parser):
'--test-apk-incremental-install-script',
type=os.path.realpath,
help='Path to install script for the test apk.')
- parser.add_argument(
- '-a', '--test-arguments',
- dest='test_arguments', default='',
- help='Additional arguments to pass to the test.')
filter_group = parser.add_mutually_exclusive_group()
filter_group.add_argument(
@@ -332,17 +342,6 @@ def AddInstrumentationTestOptions(parser):
action='store_true', dest='delete_stale_data',
help='Delete stale test data on the device.')
parser.add_argument(
- '--device-flags',
- dest='device_flags',
- type=os.path.realpath,
- help='The relative filepath to a file containing '
- 'command-line flags to set on the device')
- parser.add_argument(
- '--device-flags-file',
- type=os.path.realpath,
- help='The relative filepath to a file containing '
- 'command-line flags to set on the device')
- parser.add_argument(
'--disable-dalvik-asserts',
dest='set_asserts', action='store_false', default=True,
help='Removes the dalvik.vm.enableassertions property')
@@ -822,6 +821,7 @@ def main():
AddDeviceOptions(subp)
AddGTestOptions(subp)
AddTracingOptions(subp)
+ AddCommandLineOptions(subp)
subp = command_parsers.add_parser(
'instrumentation',
@@ -830,6 +830,7 @@ def main():
AddDeviceOptions(subp)
AddInstrumentationTestOptions(subp)
AddTracingOptions(subp)
+ AddCommandLineOptions(subp)
subp = command_parsers.add_parser(
'junit',
@@ -865,7 +866,12 @@ def main():
AddCommonOptions(subp)
AddPythonTestOptions(subp)
- args = parser.parse_args()
+ args, unknown_args = parser.parse_known_args()
+ if unknown_args:
mikecase (-- gone --) 2017/03/13 23:59:47 Do we want to do this? Now if you spell an argumen
jbudorick 2017/03/15 18:28:00 This is somewhat of a concern, but as I understand
+ if hasattr(args, 'allow_unknown') and args.allow_unknown:
+ args.command_line_flags = unknown_args
+ else:
+ parser.error('unrecognized arguments: %s' % ' '.join(unknown_args))
try:
return RunTestsCommand(args)

Powered by Google App Engine
This is Rietveld 408576698