OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Parses options for the instrumentation tests.""" | 5 """Parses options for the instrumentation tests.""" |
6 | 6 |
7 import constants | 7 import constants |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
| 10 import sys |
10 | 11 |
11 _SDK_OUT_DIR = os.path.join(constants.CHROME_DIR, 'out') | 12 _SDK_OUT_DIR = os.path.join(constants.CHROME_DIR, 'out') |
12 | 13 |
13 | 14 |
14 def AddBuildTypeOption(option_parser): | 15 def AddBuildTypeOption(option_parser): |
15 """Decorates OptionParser with build type option.""" | 16 """Decorates OptionParser with build type option.""" |
16 default_build_type = 'Debug' | 17 default_build_type = 'Debug' |
17 if 'BUILDTYPE' in os.environ: | 18 if 'BUILDTYPE' in os.environ: |
18 default_build_type = os.environ['BUILDTYPE'] | 19 default_build_type = os.environ['BUILDTYPE'] |
19 option_parser.add_option('--debug', action='store_const', const='Debug', | 20 option_parser.add_option('--debug', action='store_const', const='Debug', |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 help='Saves the JSON file for each UI Perf test.') | 96 help='Saves the JSON file for each UI Perf test.') |
96 option_parser.add_option('--shard_retries', type=int, default=1, | 97 option_parser.add_option('--shard_retries', type=int, default=1, |
97 help=('Number of times to retry each failure when ' | 98 help=('Number of times to retry each failure when ' |
98 'sharding.')) | 99 'sharding.')) |
99 option_parser.add_option('--official-build', help='Run official build tests.') | 100 option_parser.add_option('--official-build', help='Run official build tests.') |
100 option_parser.add_option('--device', | 101 option_parser.add_option('--device', |
101 help='Serial number of device we should use.') | 102 help='Serial number of device we should use.') |
102 option_parser.add_option('--python_test_root', | 103 option_parser.add_option('--python_test_root', |
103 help='Root of the python-driven tests.') | 104 help='Root of the python-driven tests.') |
104 | 105 |
105 def ValidateInstrumentationOptions(options, args): | 106 def ValidateInstrumentationOptions(option_parser, options, args): |
106 """Validate options/arguments and populate options with defaults.""" | 107 """Validate options/arguments and populate options with defaults.""" |
107 if len(args) > 1: | 108 if len(args) > 1: |
108 option_parser.error('Unknown argument:', args[1:]) | 109 option_parser.print_help(sys.stderr) |
| 110 option_parser.error('Unknown arguments: %s' % args[1:]) |
109 if options.java_only and options.python_only: | 111 if options.java_only and options.python_only: |
110 option_parser.error('Options java_only (-j) and python_only (-p) ' | 112 option_parser.error('Options java_only (-j) and python_only (-p) ' |
111 'are mutually exclusive') | 113 'are mutually exclusive.') |
112 | 114 |
113 options.run_java_tests = True | 115 options.run_java_tests = True |
114 options.run_python_tests = True | 116 options.run_python_tests = True |
115 if options.java_only: | 117 if options.java_only: |
116 options.run_python_tests = False | 118 options.run_python_tests = False |
117 elif options.python_only: | 119 elif options.python_only: |
118 options.run_java_tests = False | 120 options.run_java_tests = False |
119 | 121 |
120 options.test_apk_path = os.path.join(_SDK_OUT_DIR, | 122 options.test_apk_path = os.path.join(_SDK_OUT_DIR, |
121 options.build_type, | 123 options.build_type, |
122 '%s.apk' % options.test_apk) | 124 '%s.apk' % options.test_apk) |
123 options.test_apk_jar_path = os.path.join(_SDK_OUT_DIR, | 125 options.test_apk_jar_path = os.path.join(_SDK_OUT_DIR, |
124 options.build_type, | 126 options.build_type, |
125 '%s.jar' | 127 '%s.jar' |
126 % options.test_apk) | 128 % options.test_apk) |
127 if options.annotation_str: | 129 if options.annotation_str: |
128 options.annotation = options.annotation_str.split() | 130 options.annotation = options.annotation_str.split() |
129 elif options.test_filter: | 131 elif options.test_filter: |
130 options.annotation = [] | 132 options.annotation = [] |
131 else: | 133 else: |
132 options.annotation = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] | 134 options.annotation = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] |
133 | |
OLD | NEW |