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 content_browsertests.""" | 5 """Dispatches content_browsertests.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 | 10 |
11 from pylib import android_commands | 11 from pylib import android_commands |
12 from pylib import cmd_helper | 12 from pylib import cmd_helper |
13 from pylib import constants | 13 from pylib import constants |
14 from pylib import ports | 14 from pylib import ports |
15 from pylib.base import shard | 15 from pylib.base import shard |
16 from pylib.gtest import dispatch as gtest_dispatch | 16 from pylib.gtest import dispatch as gtest_dispatch |
17 from pylib.gtest import test_runner | 17 from pylib.gtest import test_runner |
18 from pylib.utils import report_results | 18 from pylib.utils import report_results |
19 | 19 |
20 sys.path.insert(0, | 20 sys.path.insert(0, |
21 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib')) | 21 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib')) |
22 from common import unittest_util | 22 from common import unittest_util |
23 | 23 |
24 | 24 |
25 def Dispatch(options): | 25 def Dispatch(options): |
26 """Dispatches all content_browsertests.""" | 26 """Dispatches all content_browsertests. |
| 27 |
| 28 Args: |
| 29 options: optparse.Options object containing command-line options |
| 30 Returns: |
| 31 A tuple of (base_test_result.TestRunResults object, exit code). |
| 32 Raises: |
| 33 Exception: Failed to reset the test server port. |
| 34 """ |
27 | 35 |
28 attached_devices = [] | 36 attached_devices = [] |
29 if options.test_device: | 37 if options.test_device: |
30 attached_devices = [options.test_device] | 38 attached_devices = [options.test_device] |
31 else: | 39 else: |
32 attached_devices = android_commands.GetAttachedDevices() | 40 attached_devices = android_commands.GetAttachedDevices() |
33 | 41 |
34 if not attached_devices: | 42 if not attached_devices: |
35 logging.critical('A device must be attached and online.') | 43 logging.critical('A device must be attached and online.') |
36 return 1 | 44 return 1 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 if options.test_filter: | 76 if options.test_filter: |
69 all_tests = unittest_util.FilterTestNames(all_enabled, | 77 all_tests = unittest_util.FilterTestNames(all_enabled, |
70 options.test_filter) | 78 options.test_filter) |
71 else: | 79 else: |
72 all_tests = _FilterTests(all_enabled) | 80 all_tests = _FilterTests(all_enabled) |
73 | 81 |
74 # Run tests. | 82 # Run tests. |
75 # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer | 83 # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer |
76 # files are pushed to the devices for content_browsertests: crbug.com/138275 | 84 # files are pushed to the devices for content_browsertests: crbug.com/138275 |
77 setup_timeout = 20 * 60 # 20 minutes | 85 setup_timeout = 20 * 60 # 20 minutes |
78 test_results = shard.ShardAndRunTests(RunnerFactory, attached_devices, | 86 test_results, exit_code = shard.ShardAndRunTests( |
79 all_tests, options.build_type, | 87 RunnerFactory, attached_devices, all_tests, options.build_type, |
80 setup_timeout=setup_timeout, | 88 setup_timeout=setup_timeout, test_timeout=None, |
81 test_timeout=None, | 89 num_retries=options.num_retries) |
82 num_retries=options.num_retries) | |
83 report_results.LogFull( | 90 report_results.LogFull( |
84 results=test_results, | 91 results=test_results, |
85 test_type='Unit test', | 92 test_type='Unit test', |
86 test_package=constants.BROWSERTEST_SUITE_NAME, | 93 test_package=constants.BROWSERTEST_SUITE_NAME, |
87 build_type=options.build_type, | 94 build_type=options.build_type, |
88 flakiness_server=options.flakiness_dashboard_server) | 95 flakiness_server=options.flakiness_dashboard_server) |
89 report_results.PrintAnnotation(test_results) | |
90 | 96 |
91 return len(test_results.GetNotPass()) | 97 return (test_results, exit_code) |
92 | 98 |
93 | 99 |
94 def _FilterTests(all_enabled_tests): | 100 def _FilterTests(all_enabled_tests): |
95 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" | 101 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
96 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] | 102 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
97 | 103 |
98 | 104 |
99 def _ShouldRunOnBot(test): | 105 def _ShouldRunOnBot(test): |
100 fixture, case = test.split('.', 1) | 106 fixture, case = test.split('.', 1) |
101 if _StartsWith(fixture, case, 'PRE_'): | 107 if _StartsWith(fixture, case, 'PRE_'): |
102 return False | 108 return False |
103 if _StartsWith(fixture, case, 'MANUAL_'): | 109 if _StartsWith(fixture, case, 'MANUAL_'): |
104 return False | 110 return False |
105 return True | 111 return True |
106 | 112 |
107 | 113 |
108 def _StartsWith(a, b, prefix): | 114 def _StartsWith(a, b, prefix): |
109 return a.startswith(prefix) or b.startswith(prefix) | 115 return a.startswith(prefix) or b.startswith(prefix) |
OLD | NEW |