| 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 import sys |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 | 128 |
| 129 def ValidateInstrumentationOptions(option_parser, options, args): | 129 def ValidateInstrumentationOptions(option_parser, options, args): |
| 130 """Validate options/arguments and populate options with defaults.""" | 130 """Validate options/arguments and populate options with defaults.""" |
| 131 if len(args) > 1: | 131 if len(args) > 1: |
| 132 option_parser.print_help(sys.stderr) | 132 option_parser.print_help(sys.stderr) |
| 133 option_parser.error('Unknown arguments: %s' % args[1:]) | 133 option_parser.error('Unknown arguments: %s' % args[1:]) |
| 134 if options.java_only and options.python_only: | 134 if options.java_only and options.python_only: |
| 135 option_parser.error('Options java_only (-j) and python_only (-p) ' | 135 option_parser.error('Options java_only (-j) and python_only (-p) ' |
| 136 'are mutually exclusive.') | 136 'are mutually exclusive.') |
| 137 if not options.test_apk: |
| 138 option_parser.error('--test-apk must be specified.') |
| 137 | 139 |
| 138 options.run_java_tests = True | 140 options.run_java_tests = True |
| 139 options.run_python_tests = True | 141 options.run_python_tests = True |
| 140 if options.java_only: | 142 if options.java_only: |
| 141 options.run_python_tests = False | 143 options.run_python_tests = False |
| 142 elif options.python_only: | 144 elif options.python_only: |
| 143 options.run_java_tests = False | 145 options.run_java_tests = False |
| 144 | 146 |
| 145 if os.path.exists(options.test_apk): | 147 if os.path.exists(options.test_apk): |
| 146 # The APK is fully qualified, assume the JAR lives along side. | 148 # The APK is fully qualified, assume the JAR lives along side. |
| 147 options.test_apk_path = options.test_apk | 149 options.test_apk_path = options.test_apk |
| 148 options.test_apk_jar_path = os.path.splitext(options.test_apk_path) + '.jar' | 150 options.test_apk_jar_path = os.path.splitext(options.test_apk_path) + '.jar' |
| 149 else: | 151 else: |
| 150 options.test_apk_path = os.path.join(_SDK_OUT_DIR, | 152 options.test_apk_path = os.path.join(_SDK_OUT_DIR, |
| 151 options.build_type, | 153 options.build_type, |
| 152 constants.SDK_BUILD_APKS_DIR, | 154 constants.SDK_BUILD_APKS_DIR, |
| 153 '%s.apk' % options.test_apk) | 155 '%s.apk' % options.test_apk) |
| 154 options.test_apk_jar_path = os.path.join( | 156 options.test_apk_jar_path = os.path.join( |
| 155 _SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_TEST_JAVALIB_DIR, | 157 _SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_TEST_JAVALIB_DIR, |
| 156 '%s.jar' % options.test_apk) | 158 '%s.jar' % options.test_apk) |
| 157 if options.annotation_str: | 159 if options.annotation_str: |
| 158 options.annotation = options.annotation_str.split() | 160 options.annotation = options.annotation_str.split() |
| 159 elif options.test_filter: | 161 elif options.test_filter: |
| 160 options.annotation = [] | 162 options.annotation = [] |
| 161 else: | 163 else: |
| 162 options.annotation = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] | 164 options.annotation = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] |
| OLD | NEW |