OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 import sys | 4 import sys |
5 | 5 |
6 from telemetry.core import util | 6 from telemetry.core import util |
7 from telemetry import decorators | 7 from telemetry import decorators |
8 from telemetry.internal.browser import browser_finder | 8 from telemetry.internal.browser import browser_finder |
9 from telemetry.internal.browser import browser_finder_exceptions | 9 from telemetry.internal.browser import browser_finder_exceptions |
10 from telemetry.internal.browser import browser_options | 10 from telemetry.internal.browser import browser_options |
11 from telemetry.internal.platform import device_finder | 11 from telemetry.internal.platform import device_finder |
| 12 from telemetry.internal.util import binary_manager |
12 from telemetry.internal.util import command_line | 13 from telemetry.internal.util import command_line |
13 from telemetry.testing import browser_test_case | 14 from telemetry.testing import browser_test_case |
14 from telemetry.testing import options_for_unittests | 15 from telemetry.testing import options_for_unittests |
15 | 16 |
16 util.AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'typ') | 17 util.AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'typ') |
17 | 18 |
18 import typ | 19 import typ |
19 | 20 |
20 | 21 |
21 class RunTestsCommand(command_line.OptparseCommand): | 22 class RunTestsCommand(command_line.OptparseCommand): |
(...skipping 16 matching lines...) Expand all Loading... |
38 def AddCommandLineArgs(cls, parser, _): | 39 def AddCommandLineArgs(cls, parser, _): |
39 parser.add_option('--repeat-count', type='int', default=1, | 40 parser.add_option('--repeat-count', type='int', default=1, |
40 help='Repeats each a provided number of times.') | 41 help='Repeats each a provided number of times.') |
41 parser.add_option('-d', '--also-run-disabled-tests', | 42 parser.add_option('-d', '--also-run-disabled-tests', |
42 dest='run_disabled_tests', | 43 dest='run_disabled_tests', |
43 action='store_true', default=False, | 44 action='store_true', default=False, |
44 help='Ignore @Disabled and @Enabled restrictions.') | 45 help='Ignore @Disabled and @Enabled restrictions.') |
45 parser.add_option('--exact-test-filter', action='store_true', default=False, | 46 parser.add_option('--exact-test-filter', action='store_true', default=False, |
46 help='Treat test filter as exact matches (default is ' | 47 help='Treat test filter as exact matches (default is ' |
47 'substring matches).') | 48 'substring matches).') |
| 49 parser.add_option('--client-config', dest='client_config', default=None) |
48 | 50 |
49 typ.ArgumentParser.add_option_group(parser, | 51 typ.ArgumentParser.add_option_group(parser, |
50 "Options for running the tests", | 52 "Options for running the tests", |
51 running=True, | 53 running=True, |
52 skip=['-d', '-v', '--verbose']) | 54 skip=['-d', '-v', '--verbose']) |
53 typ.ArgumentParser.add_option_group(parser, | 55 typ.ArgumentParser.add_option_group(parser, |
54 "Options for reporting the results", | 56 "Options for reporting the results", |
55 reporting=True) | 57 reporting=True) |
56 | 58 |
57 @classmethod | 59 @classmethod |
(...skipping 13 matching lines...) Expand all Loading... |
71 'Re-run with --browser=list to see ' | 73 'Re-run with --browser=list to see ' |
72 'available browser types.' % args.browser_type) | 74 'available browser types.' % args.browser_type) |
73 | 75 |
74 @classmethod | 76 @classmethod |
75 def main(cls, args=None, stream=None): # pylint: disable=W0221 | 77 def main(cls, args=None, stream=None): # pylint: disable=W0221 |
76 # We override the superclass so that we can hook in the 'stream' arg. | 78 # We override the superclass so that we can hook in the 'stream' arg. |
77 parser = cls.CreateParser() | 79 parser = cls.CreateParser() |
78 cls.AddCommandLineArgs(parser, None) | 80 cls.AddCommandLineArgs(parser, None) |
79 options, positional_args = parser.parse_args(args) | 81 options, positional_args = parser.parse_args(args) |
80 options.positional_args = positional_args | 82 options.positional_args = positional_args |
| 83 |
| 84 # Must initialize the DependencyManager before calling |
| 85 # browser_finder.FindBrowser(args) |
| 86 binary_manager.InitDependencyManager(options.client_config) |
81 cls.ProcessCommandLineArgs(parser, options, None) | 87 cls.ProcessCommandLineArgs(parser, options, None) |
82 | 88 |
83 obj = cls() | 89 obj = cls() |
84 if stream is not None: | 90 if stream is not None: |
85 obj.stream = stream | 91 obj.stream = stream |
86 return obj.Run(options) | 92 return obj.Run(options) |
87 | 93 |
88 def Run(self, args): | 94 def Run(self, args): |
89 possible_browser = browser_finder.FindBrowser(args) | 95 possible_browser = browser_finder.FindBrowser(args) |
90 | 96 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 def _MatchesSelectedTest(name, selected_tests, selected_tests_are_exact): | 167 def _MatchesSelectedTest(name, selected_tests, selected_tests_are_exact): |
162 if not selected_tests: | 168 if not selected_tests: |
163 return False | 169 return False |
164 if selected_tests_are_exact: | 170 if selected_tests_are_exact: |
165 return any(name in selected_tests) | 171 return any(name in selected_tests) |
166 else: | 172 else: |
167 return any(test in name for test in selected_tests) | 173 return any(test in name for test in selected_tests) |
168 | 174 |
169 | 175 |
170 def _SetUpProcess(child, context): # pylint: disable=W0613 | 176 def _SetUpProcess(child, context): # pylint: disable=W0613 |
| 177 if binary_manager.NeedsInit(): |
| 178 # Typ doesn't keep the DependencyManager initialization in the child |
| 179 # processes. |
| 180 binary_manager.InitDependencyManager(context.client_config) |
| 181 |
171 args = context | 182 args = context |
172 if args.device and args.device == 'android': | 183 if args.device and args.device == 'android': |
173 android_devices = device_finder.GetDevicesMatchingOptions(args) | 184 android_devices = device_finder.GetDevicesMatchingOptions(args) |
174 args.device = android_devices[child.worker_num-1].guid | 185 args.device = android_devices[child.worker_num-1].guid |
175 options_for_unittests.Push(args) | 186 options_for_unittests.Push(args) |
176 | 187 |
177 | 188 |
178 def _TearDownProcess(child, context): # pylint: disable=W0613 | 189 def _TearDownProcess(child, context): # pylint: disable=W0613 |
179 browser_test_case.teardown_browser() | 190 browser_test_case.teardown_browser() |
180 options_for_unittests.Pop() | 191 options_for_unittests.Pop() |
181 | 192 |
182 | 193 |
183 if __name__ == '__main__': | 194 if __name__ == '__main__': |
184 ret_code = RunTestsCommand.main() | 195 ret_code = RunTestsCommand.main() |
185 sys.exit(ret_code) | 196 sys.exit(ret_code) |
OLD | NEW |