| 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 #TODO(craigdh): pylib/utils/ should not depend on pylib/. | 7 #TODO(craigdh): pylib/utils/ should not depend on pylib/. |
| 8 from pylib import constants | 8 from pylib import constants |
| 9 | 9 |
| 10 import optparse | 10 import optparse |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 AddTestRunnerOptions(option_parser) | 137 AddTestRunnerOptions(option_parser) |
| 138 option_parser.add_option('-f', '--test_filter', | 138 option_parser.add_option('-f', '--test_filter', |
| 139 help='Test filter (if not fully qualified, ' | 139 help='Test filter (if not fully qualified, ' |
| 140 'will run all matches).') | 140 'will run all matches).') |
| 141 option_parser.add_option( | 141 option_parser.add_option( |
| 142 '-A', '--annotation', dest='annotation_str', | 142 '-A', '--annotation', dest='annotation_str', |
| 143 help=('Comma-separated list of annotations. Run only tests with any of ' | 143 help=('Comma-separated list of annotations. Run only tests with any of ' |
| 144 'the given annotations. An annotation can be either a key or a ' | 144 'the given annotations. An annotation can be either a key or a ' |
| 145 'key-values pair. A test that has no annotation is considered ' | 145 'key-values pair. A test that has no annotation is considered ' |
| 146 '"SmallTest".')) | 146 '"SmallTest".')) |
| 147 option_parser.add_option( |
| 148 '-E', '--exclude-annotation', dest='exclude_annotation_str', |
| 149 help=('Comma-separated list of annotations. Exclude tests with these ' |
| 150 'annotations.')) |
| 147 option_parser.add_option('-j', '--java_only', action='store_true', | 151 option_parser.add_option('-j', '--java_only', action='store_true', |
| 148 help='Run only the Java tests.') | 152 help='Run only the Java tests.') |
| 149 option_parser.add_option('-p', '--python_only', action='store_true', | 153 option_parser.add_option('-p', '--python_only', action='store_true', |
| 150 help='Run only the Python tests.') | 154 help='Run only the Python tests.') |
| 151 option_parser.add_option('--screenshot', dest='screenshot_failures', | 155 option_parser.add_option('--screenshot', dest='screenshot_failures', |
| 152 action='store_true', | 156 action='store_true', |
| 153 help='Capture screenshots of test failures') | 157 help='Capture screenshots of test failures') |
| 154 option_parser.add_option('--save-perf-json', action='store_true', | 158 option_parser.add_option('--save-perf-json', action='store_true', |
| 155 help='Saves the JSON file for each UI Perf test.') | 159 help='Saves the JSON file for each UI Perf test.') |
| 156 option_parser.add_option('--shard_retries', type=int, default=1, | 160 option_parser.add_option('--shard_retries', type=int, default=1, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 elif options.python_only: | 233 elif options.python_only: |
| 230 options.run_java_tests = False | 234 options.run_java_tests = False |
| 231 | 235 |
| 232 if options.annotation_str: | 236 if options.annotation_str: |
| 233 options.annotations = options.annotation_str.split(',') | 237 options.annotations = options.annotation_str.split(',') |
| 234 elif options.test_filter: | 238 elif options.test_filter: |
| 235 options.annotations = [] | 239 options.annotations = [] |
| 236 else: | 240 else: |
| 237 options.annotations = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] | 241 options.annotations = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] |
| 238 | 242 |
| 243 if options.exclude_annotation_str: |
| 244 options.exclude_annotations = options.exclude_annotation_str.split(',') |
| 245 else: |
| 246 options.exclude_annotations = [] |
| 247 |
| 239 | 248 |
| 240 def ValidateInstrumentationOptions(option_parser, options, args): | 249 def ValidateInstrumentationOptions(option_parser, options, args): |
| 241 """Validate options/arguments and populate options with defaults.""" | 250 """Validate options/arguments and populate options with defaults.""" |
| 242 ValidateCommonInstrumentationOptions(option_parser, options, args) | 251 ValidateCommonInstrumentationOptions(option_parser, options, args) |
| 243 | 252 |
| 244 if not options.test_apk: | 253 if not options.test_apk: |
| 245 option_parser.error('--test-apk must be specified.') | 254 option_parser.error('--test-apk must be specified.') |
| 246 | 255 |
| 247 if os.path.exists(options.test_apk): | 256 if os.path.exists(options.test_apk): |
| 248 # The APK is fully qualified, assume the JAR lives along side. | 257 # The APK is fully qualified, assume the JAR lives along side. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 273 # The dexed JAR is fully qualified, assume the info JAR lives along side. | 282 # The dexed JAR is fully qualified, assume the info JAR lives along side. |
| 274 options.uiautomator_jar = options.test_jar | 283 options.uiautomator_jar = options.test_jar |
| 275 else: | 284 else: |
| 276 options.uiautomator_jar = os.path.join( | 285 options.uiautomator_jar = os.path.join( |
| 277 _SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_JAVALIB_DIR, | 286 _SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_JAVALIB_DIR, |
| 278 '%s.dex.jar' % options.test_jar) | 287 '%s.dex.jar' % options.test_jar) |
| 279 options.uiautomator_info_jar = ( | 288 options.uiautomator_info_jar = ( |
| 280 options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] + | 289 options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] + |
| 281 '_java.jar') | 290 '_java.jar') |
| 282 | 291 |
| OLD | NEW |