| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import collections | 5 import collections |
| 6 import copy | 6 import copy |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import pickle | 9 import pickle |
| 10 import re | 10 import re |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 self._driver_apk = None | 224 self._driver_apk = None |
| 225 self._driver_package = None | 225 self._driver_package = None |
| 226 self._driver_name = None | 226 self._driver_name = None |
| 227 self._initializeDriverAttributes() | 227 self._initializeDriverAttributes() |
| 228 | 228 |
| 229 self._timeout_scale = None | 229 self._timeout_scale = None |
| 230 self._initializeTestControlAttributes(args) | 230 self._initializeTestControlAttributes(args) |
| 231 | 231 |
| 232 def _initializeApkAttributes(self, args, error_func): | 232 def _initializeApkAttributes(self, args, error_func): |
| 233 apk_under_test_path = args.apk_under_test | 233 if args.apk_under_test: |
| 234 if not args.apk_under_test.endswith('.apk'): | 234 apk_under_test_path = args.apk_under_test |
| 235 apk_under_test_path = os.path.join( | 235 if not args.apk_under_test.endswith('.apk'): |
| 236 constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR, | 236 apk_under_test_path = os.path.join( |
| 237 '%s.apk' % args.apk_under_test) | 237 constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR, |
| 238 '%s.apk' % args.apk_under_test) |
| 238 | 239 |
| 239 if not os.path.exists(apk_under_test_path): | 240 if not os.path.exists(apk_under_test_path): |
| 240 error_func('Unable to find APK under test: %s' % apk_under_test_path) | 241 error_func('Unable to find APK under test: %s' % apk_under_test_path) |
| 241 | 242 |
| 242 self._apk_under_test = apk_helper.ToHelper(apk_under_test_path) | 243 self._apk_under_test = apk_helper.ToHelper(apk_under_test_path) |
| 243 | 244 |
| 244 if args.test_apk.endswith('.apk'): | 245 if args.test_apk.endswith('.apk'): |
| 245 self._suite = os.path.splitext(os.path.basename(args.test_apk))[0] | 246 self._suite = os.path.splitext(os.path.basename(args.test_apk))[0] |
| 246 self._test_apk = apk_helper.ToHelper(args.test_apk) | 247 self._test_apk = apk_helper.ToHelper(args.test_apk) |
| 247 else: | 248 else: |
| 248 self._suite = args.test_apk | 249 self._suite = args.test_apk |
| 249 self._test_apk = apk_helper.ToHelper(os.path.join( | 250 self._test_apk = apk_helper.ToHelper(os.path.join( |
| 250 constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR, | 251 constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR, |
| 251 '%s.apk' % args.test_apk)) | 252 '%s.apk' % args.test_apk)) |
| 252 | 253 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 283 | 284 |
| 284 for apk in args.additional_apks: | 285 for apk in args.additional_apks: |
| 285 if not os.path.exists(apk): | 286 if not os.path.exists(apk): |
| 286 error_func('Unable to find additional APK: %s' % apk) | 287 error_func('Unable to find additional APK: %s' % apk) |
| 287 self._additional_apks = ( | 288 self._additional_apks = ( |
| 288 [apk_helper.ToHelper(x) for x in args.additional_apks]) | 289 [apk_helper.ToHelper(x) for x in args.additional_apks]) |
| 289 | 290 |
| 290 def _initializeDataDependencyAttributes(self, args, isolate_delegate): | 291 def _initializeDataDependencyAttributes(self, args, isolate_delegate): |
| 291 self._data_deps = [] | 292 self._data_deps = [] |
| 292 if args.isolate_file_path: | 293 if args.isolate_file_path: |
| 293 self._isolate_abs_path = os.path.abspath(args.isolate_file_path) | 294 if os.path.isabs(args.isolate_file_path): |
| 295 self._isolate_abs_path = args.isolate_file_path |
| 296 else: |
| 297 self._isolate_abs_path = os.path.join( |
| 298 constants.DIR_SOURCE_ROOT, args.isolate_file_path) |
| 294 self._isolate_delegate = isolate_delegate | 299 self._isolate_delegate = isolate_delegate |
| 295 self._isolated_abs_path = os.path.join( | 300 self._isolated_abs_path = os.path.join( |
| 296 constants.GetOutDirectory(), '%s.isolated' % self._test_package) | 301 constants.GetOutDirectory(), '%s.isolated' % self._test_package) |
| 297 else: | 302 else: |
| 298 self._isolate_delegate = None | 303 self._isolate_delegate = None |
| 299 | 304 |
| 300 # TODO(jbudorick): Deprecate and remove --test-data once data dependencies | 305 # TODO(jbudorick): Deprecate and remove --test-data once data dependencies |
| 301 # are fully converted to isolate. | 306 # are fully converted to isolate. |
| 302 if args.test_data: | 307 if args.test_data: |
| 303 logging.info('Data dependencies specified via --test-data') | 308 logging.info('Data dependencies specified via --test-data') |
| 304 self._test_data = args.test_data | 309 self._test_data = args.test_data |
| 305 else: | 310 else: |
| 306 self._test_data = None | 311 self._test_data = None |
| 307 | 312 |
| 308 if not self._isolate_delegate and not self._test_data: | 313 if not self._isolate_delegate and not self._test_data: |
| 309 logging.warning('No data dependencies will be pushed.') | 314 logging.warning('No data dependencies will be pushed.') |
| 310 | 315 |
| 311 def _initializeTestFilterAttributes(self, args): | 316 def _initializeTestFilterAttributes(self, args): |
| 312 self._test_filter = args.test_filter | 317 if args.test_filter: |
| 318 self._test_filter = args.test_filter.replace('#', '.') |
| 313 | 319 |
| 314 def annotation_dict_element(a): | 320 def annotation_dict_element(a): |
| 315 a = a.split('=') | 321 a = a.split('=') |
| 316 return (a[0], a[1] if len(a) == 2 else None) | 322 return (a[0], a[1] if len(a) == 2 else None) |
| 317 | 323 |
| 318 if args.annotation_str: | 324 if args.annotation_str: |
| 319 self._annotations = dict( | 325 self._annotations = dict( |
| 320 annotation_dict_element(a) | 326 annotation_dict_element(a) |
| 321 for a in args.annotation_str.split(',')) | 327 for a in args.annotation_str.split(',')) |
| 322 elif not self._test_filter: | 328 elif not self._test_filter: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 333 else: | 339 else: |
| 334 self._excluded_annotations = {} | 340 self._excluded_annotations = {} |
| 335 | 341 |
| 336 self._excluded_annotations.update( | 342 self._excluded_annotations.update( |
| 337 { | 343 { |
| 338 a: None for a in _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS | 344 a: None for a in _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS |
| 339 if a not in self._annotations | 345 if a not in self._annotations |
| 340 }) | 346 }) |
| 341 | 347 |
| 342 def _initializeFlagAttributes(self, args): | 348 def _initializeFlagAttributes(self, args): |
| 343 self._flags = ['--disable-fre', '--enable-test-intents'] | 349 self._flags = ['--enable-test-intents'] |
| 344 # TODO(jbudorick): Transition "--device-flags" to "--device-flags-file" | 350 # TODO(jbudorick): Transition "--device-flags" to "--device-flags-file" |
| 345 if hasattr(args, 'device_flags') and args.device_flags: | 351 if hasattr(args, 'device_flags') and args.device_flags: |
| 346 with open(args.device_flags) as device_flags_file: | 352 with open(args.device_flags) as device_flags_file: |
| 347 stripped_lines = (l.strip() for l in device_flags_file) | 353 stripped_lines = (l.strip() for l in device_flags_file) |
| 348 self._flags.extend([flag for flag in stripped_lines if flag]) | 354 self._flags.extend([flag for flag in stripped_lines if flag]) |
| 349 if hasattr(args, 'device_flags_file') and args.device_flags_file: | 355 if hasattr(args, 'device_flags_file') and args.device_flags_file: |
| 350 with open(args.device_flags_file) as device_flags_file: | 356 with open(args.device_flags_file) as device_flags_file: |
| 351 stripped_lines = (l.strip() for l in device_flags_file) | 357 stripped_lines = (l.strip() for l in device_flags_file) |
| 352 self._flags.extend([flag for flag in stripped_lines if flag]) | 358 self._flags.extend([flag for flag in stripped_lines if flag]) |
| 353 if (hasattr(args, 'strict_mode') and | 359 if (hasattr(args, 'strict_mode') and |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 def GenerateTestResults( | 635 def GenerateTestResults( |
| 630 result_code, result_bundle, statuses, start_ms, duration_ms): | 636 result_code, result_bundle, statuses, start_ms, duration_ms): |
| 631 return GenerateTestResults(result_code, result_bundle, statuses, | 637 return GenerateTestResults(result_code, result_bundle, statuses, |
| 632 start_ms, duration_ms) | 638 start_ms, duration_ms) |
| 633 | 639 |
| 634 #override | 640 #override |
| 635 def TearDown(self): | 641 def TearDown(self): |
| 636 if self._isolate_delegate: | 642 if self._isolate_delegate: |
| 637 self._isolate_delegate.Clear() | 643 self._isolate_delegate.Clear() |
| 638 | 644 |
| OLD | NEW |