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

Side by Side Diff: build/android/pylib/instrumentation/instrumentation_test_instance.py

Issue 2502363005: [android] Stop using isolate.py for data dependency management. (RELAND) (Closed)
Patch Set: fixed: moved the runtime_deps file. Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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
11 11
12 from devil.android import apk_helper 12 from devil.android import apk_helper
13 from devil.android import md5sum 13 from devil.android import md5sum
14 from pylib import constants 14 from pylib import constants
15 from pylib.base import base_test_result 15 from pylib.base import base_test_result
16 from pylib.base import test_exception 16 from pylib.base import test_exception
17 from pylib.base import test_instance 17 from pylib.base import test_instance
18 from pylib.constants import host_paths 18 from pylib.constants import host_paths
19 from pylib.instrumentation import test_result 19 from pylib.instrumentation import test_result
20 from pylib.instrumentation import instrumentation_parser 20 from pylib.instrumentation import instrumentation_parser
21 from pylib.utils import isolator
22 from pylib.utils import proguard 21 from pylib.utils import proguard
23 22
24 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): 23 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH):
25 import unittest_util # pylint: disable=import-error 24 import unittest_util # pylint: disable=import-error
26 25
27 # Ref: http://developer.android.com/reference/android/app/Activity.html 26 # Ref: http://developer.android.com/reference/android/app/Activity.html
28 _ACTIVITY_RESULT_CANCELED = 0 27 _ACTIVITY_RESULT_CANCELED = 0
29 _ACTIVITY_RESULT_OK = -1 28 _ACTIVITY_RESULT_OK = -1
30 29
31 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter' 30 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter'
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 flags = test['flags'] 392 flags = test['flags']
394 if flags.add: 393 if flags.add:
395 display_name = '%s with {%s}' % (display_name, ' '.join(flags.add)) 394 display_name = '%s with {%s}' % (display_name, ' '.join(flags.add))
396 if flags.remove: 395 if flags.remove:
397 display_name = '%s without {%s}' % (display_name, ' '.join(flags.remove)) 396 display_name = '%s without {%s}' % (display_name, ' '.join(flags.remove))
398 return display_name 397 return display_name
399 398
400 399
401 class InstrumentationTestInstance(test_instance.TestInstance): 400 class InstrumentationTestInstance(test_instance.TestInstance):
402 401
403 def __init__(self, args, isolate_delegate, error_func): 402 def __init__(self, args, data_deps_delegate, error_func):
404 super(InstrumentationTestInstance, self).__init__() 403 super(InstrumentationTestInstance, self).__init__()
405 404
406 self._additional_apks = [] 405 self._additional_apks = []
407 self._apk_under_test = None 406 self._apk_under_test = None
408 self._apk_under_test_incremental_install_script = None 407 self._apk_under_test_incremental_install_script = None
409 self._package_info = None 408 self._package_info = None
410 self._suite = None 409 self._suite = None
411 self._test_apk = None 410 self._test_apk = None
412 self._test_apk_incremental_install_script = None 411 self._test_apk_incremental_install_script = None
413 self._test_jar = None 412 self._test_jar = None
414 self._test_package = None 413 self._test_package = None
415 self._test_runner = None 414 self._test_runner = None
416 self._test_support_apk = None 415 self._test_support_apk = None
417 self._initializeApkAttributes(args, error_func) 416 self._initializeApkAttributes(args, error_func)
418 417
419 self._data_deps = None 418 self._data_deps = None
420 self._isolate_abs_path = None 419 self._data_deps_delegate = None
421 self._isolate_delegate = None 420 self._runtime_deps_path = None
422 self._isolated_abs_path = None 421 self._initializeDataDependencyAttributes(args, data_deps_delegate)
423 self._initializeDataDependencyAttributes(args, isolate_delegate)
424 422
425 self._annotations = None 423 self._annotations = None
426 self._excluded_annotations = None 424 self._excluded_annotations = None
427 self._test_filter = None 425 self._test_filter = None
428 self._initializeTestFilterAttributes(args) 426 self._initializeTestFilterAttributes(args)
429 427
430 self._flags = None 428 self._flags = None
431 self._initializeFlagAttributes(args) 429 self._initializeFlagAttributes(args)
432 430
433 self._driver_apk = None 431 self._driver_apk = None
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 break 511 break
514 if not self._package_info: 512 if not self._package_info:
515 logging.warning('Unable to find package info for %s', self._test_package) 513 logging.warning('Unable to find package info for %s', self._test_package)
516 514
517 for apk in args.additional_apks: 515 for apk in args.additional_apks:
518 if not os.path.exists(apk): 516 if not os.path.exists(apk):
519 error_func('Unable to find additional APK: %s' % apk) 517 error_func('Unable to find additional APK: %s' % apk)
520 self._additional_apks = ( 518 self._additional_apks = (
521 [apk_helper.ToHelper(x) for x in args.additional_apks]) 519 [apk_helper.ToHelper(x) for x in args.additional_apks])
522 520
523 def _initializeDataDependencyAttributes(self, args, isolate_delegate): 521 def _initializeDataDependencyAttributes(self, args, data_deps_delegate):
524 self._data_deps = [] 522 self._data_deps = []
525 if (args.isolate_file_path and 523 self._data_deps_delegate = data_deps_delegate
526 not isolator.IsIsolateEmpty(args.isolate_file_path)): 524 self._runtime_deps_path = args.runtime_deps_path
527 if os.path.isabs(args.isolate_file_path):
528 self._isolate_abs_path = args.isolate_file_path
529 else:
530 self._isolate_abs_path = os.path.join(
531 constants.DIR_SOURCE_ROOT, args.isolate_file_path)
532 self._isolate_delegate = isolate_delegate
533 self._isolated_abs_path = os.path.join(
534 constants.GetOutDirectory(), '%s.isolated' % self._test_package)
535 else:
536 self._isolate_delegate = None
537 525
538 if not self._isolate_delegate: 526 if not self._runtime_deps_path:
539 logging.warning('No data dependencies will be pushed.') 527 logging.warning('No data dependencies will be pushed.')
540 528
541 def _initializeTestFilterAttributes(self, args): 529 def _initializeTestFilterAttributes(self, args):
542 if args.test_filter: 530 if args.test_filter:
543 self._test_filter = _CMDLINE_NAME_SEGMENT_RE.sub( 531 self._test_filter = _CMDLINE_NAME_SEGMENT_RE.sub(
544 '', args.test_filter.replace('#', '.')) 532 '', args.test_filter.replace('#', '.'))
545 533
546 def annotation_element(a): 534 def annotation_element(a):
547 a = a.split('=', 1) 535 a = a.split('=', 1)
548 return (a[0], a[1] if len(a) == 2 else None) 536 return (a[0], a[1] if len(a) == 2 else None)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 @property 669 @property
682 def timeout_scale(self): 670 def timeout_scale(self):
683 return self._timeout_scale 671 return self._timeout_scale
684 672
685 #override 673 #override
686 def TestType(self): 674 def TestType(self):
687 return 'instrumentation' 675 return 'instrumentation'
688 676
689 #override 677 #override
690 def SetUp(self): 678 def SetUp(self):
691 if self._isolate_delegate: 679 self._data_deps.extend(
692 self._isolate_delegate.Remap( 680 self._data_deps_delegate(self._runtime_deps_path))
693 self._isolate_abs_path, self._isolated_abs_path)
694 self._isolate_delegate.MoveOutputDeps()
695 self._data_deps.extend([(self._isolate_delegate.isolate_deps_dir, None)])
696 681
697 def GetDataDependencies(self): 682 def GetDataDependencies(self):
698 return self._data_deps 683 return self._data_deps
699 684
700 def GetTests(self): 685 def GetTests(self):
701 tests = GetAllTests(self.test_jar) 686 tests = GetAllTests(self.test_jar)
702 inflated_tests = self._ParametrizeTestsWithFlags(self._InflateTests(tests)) 687 inflated_tests = self._ParametrizeTestsWithFlags(self._InflateTests(tests))
703 filtered_tests = FilterTests( 688 filtered_tests = FilterTests(
704 inflated_tests, self._test_filter, self._annotations, 689 inflated_tests, self._test_filter, self._annotations,
705 self._excluded_annotations) 690 self._excluded_annotations)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 return ParseAmInstrumentRawOutput(raw_output) 742 return ParseAmInstrumentRawOutput(raw_output)
758 743
759 @staticmethod 744 @staticmethod
760 def GenerateTestResults( 745 def GenerateTestResults(
761 result_code, result_bundle, statuses, start_ms, duration_ms): 746 result_code, result_bundle, statuses, start_ms, duration_ms):
762 return GenerateTestResults(result_code, result_bundle, statuses, 747 return GenerateTestResults(result_code, result_bundle, statuses,
763 start_ms, duration_ms) 748 start_ms, duration_ms)
764 749
765 #override 750 #override
766 def TearDown(self): 751 def TearDown(self):
767 if self._isolate_delegate: 752 pass
768 self._isolate_delegate.Clear()
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/gtest_test_instance.py ('k') | build/android/pylib/local/device/local_device_gtest_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698