OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 """Dispatches the instrumentation tests.""" | 5 """Dispatches the instrumentation tests.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 | 9 |
10 from pylib import android_commands | 10 from pylib import android_commands |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 tests_missing_annotations = _GetTestsMissingAnnotation(test_pkg) | 60 tests_missing_annotations = _GetTestsMissingAnnotation(test_pkg) |
61 if tests_missing_annotations: | 61 if tests_missing_annotations: |
62 logging.warning('The following tests do not contain any annotation. ' | 62 logging.warning('The following tests do not contain any annotation. ' |
63 'Assuming "%s":\n%s', | 63 'Assuming "%s":\n%s', |
64 default_size_annotation, | 64 default_size_annotation, |
65 '\n'.join(tests_missing_annotations)) | 65 '\n'.join(tests_missing_annotations)) |
66 available_tests += tests_missing_annotations | 66 available_tests += tests_missing_annotations |
67 else: | 67 else: |
68 available_tests = [m for m in test_pkg.GetTestMethods() | 68 available_tests = [m for m in test_pkg.GetTestMethods() |
69 if not test_pkg.IsPythonDrivenTest(m)] | 69 if not test_pkg.IsPythonDrivenTest(m)] |
70 coverage = os.environ.get('EMMA_INSTRUMENT') == 'true' | |
71 | 70 |
72 tests = [] | 71 tests = [] |
73 if options.test_filter: | 72 if options.test_filter: |
74 # |available_tests| are in adb instrument format: package.path.class#test. | 73 # |available_tests| are in adb instrument format: package.path.class#test. |
75 filter_without_hash = options.test_filter.replace('#', '.') | 74 filter_without_hash = options.test_filter.replace('#', '.') |
76 tests = [t for t in available_tests | 75 tests = [t for t in available_tests |
77 if filter_without_hash in t.replace('#', '.')] | 76 if filter_without_hash in t.replace('#', '.')] |
78 else: | 77 else: |
79 tests = available_tests | 78 tests = available_tests |
80 | 79 |
81 if not tests: | 80 if not tests: |
82 logging.warning('No instrumentation tests to run with current args.') | 81 logging.warning('No instrumentation tests to run with current args.') |
83 return base_test_result.TestRunResults() | 82 return base_test_result.TestRunResults() |
84 | 83 |
85 tests *= options.number_of_runs | 84 tests *= options.number_of_runs |
86 | 85 |
87 attached_devices = android_commands.GetAttachedDevices() | 86 attached_devices = android_commands.GetAttachedDevices() |
88 | 87 |
89 if not attached_devices: | 88 if not attached_devices: |
90 raise Exception('There are no devices online.') | 89 raise Exception('There are no devices online.') |
91 if options.device: | 90 if options.device: |
92 attached_devices = [options.device] | 91 attached_devices = [options.device] |
93 | 92 |
94 logging.info('Will run: %s', str(tests)) | 93 logging.info('Will run: %s', str(tests)) |
95 | 94 |
96 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 95 if len(attached_devices) > 1 and options.wait_for_debugger: |
97 logging.warning('Coverage / debugger can not be sharded, ' | 96 logging.warning('Debugger can not be sharded, using first available device') |
98 'using first available device') | |
99 attached_devices = attached_devices[:1] | 97 attached_devices = attached_devices[:1] |
100 | 98 |
101 def TestRunnerFactory(device, shard_index): | 99 def TestRunnerFactory(device, shard_index): |
102 return test_runner.TestRunner( | 100 return test_runner.TestRunner( |
103 options, device, shard_index, False, test_pkg, [], is_uiautomator_test) | 101 options, device, shard_index, test_pkg, [], is_uiautomator_test) |
104 | 102 |
105 return shard.ShardAndRunTests(TestRunnerFactory, attached_devices, tests, | 103 return shard.ShardAndRunTests(TestRunnerFactory, attached_devices, tests, |
106 options.build_type) | 104 options.build_type) |
OLD | NEW |