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): |
frankf
2013/07/03 21:26:37
Future TODO: There's a lot of duplicaiton in dispa
gkanwar
2013/07/03 23:15:18
Agreed. Should I file a bug for this perhaps?
| |
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 base_test_result.TestRunResults object with the results of running the tests | |
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 test_timeout=None, | 89 test_timeout=None, |
82 num_retries=options.num_retries) | 90 num_retries=options.num_retries) |
83 report_results.LogFull( | 91 report_results.LogFull( |
84 results=test_results, | 92 results=test_results, |
85 test_type='Unit test', | 93 test_type='Unit test', |
86 test_package=constants.BROWSERTEST_SUITE_NAME, | 94 test_package=constants.BROWSERTEST_SUITE_NAME, |
87 build_type=options.build_type, | 95 build_type=options.build_type, |
88 flakiness_server=options.flakiness_dashboard_server) | 96 flakiness_server=options.flakiness_dashboard_server) |
89 report_results.PrintAnnotation(test_results) | 97 report_results.PrintAnnotation(test_results) |
90 | 98 |
91 return len(test_results.GetNotPass()) | 99 return test_results |
92 | 100 |
93 | 101 |
94 def _FilterTests(all_enabled_tests): | 102 def _FilterTests(all_enabled_tests): |
95 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" | 103 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
96 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] | 104 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
97 | 105 |
98 | 106 |
99 def _ShouldRunOnBot(test): | 107 def _ShouldRunOnBot(test): |
100 fixture, case = test.split('.', 1) | 108 fixture, case = test.split('.', 1) |
101 if _StartsWith(fixture, case, 'PRE_'): | 109 if _StartsWith(fixture, case, 'PRE_'): |
102 return False | 110 return False |
103 if _StartsWith(fixture, case, 'MANUAL_'): | 111 if _StartsWith(fixture, case, 'MANUAL_'): |
104 return False | 112 return False |
105 return True | 113 return True |
106 | 114 |
107 | 115 |
108 def _StartsWith(a, b, prefix): | 116 def _StartsWith(a, b, prefix): |
109 return a.startswith(prefix) or b.startswith(prefix) | 117 return a.startswith(prefix) or b.startswith(prefix) |
OLD | NEW |