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 import logging | 5 import logging |
6 import os | 6 import os |
7 | 7 |
8 from pylib import android_commands | 8 from pylib import android_commands |
9 from pylib import cmd_helper | 9 from pylib import cmd_helper |
10 from pylib import constants | 10 from pylib import constants |
11 from pylib import ports | 11 from pylib import ports |
12 from pylib.base import shard | 12 from pylib.base import shard |
13 from pylib.gtest import dispatch as gtest_dispatch | 13 from pylib.gtest import dispatch as gtest_dispatch |
14 from pylib.gtest import test_runner | 14 from pylib.gtest import test_runner |
| 15 from pylib.utils import report_results |
| 16 |
15 | 17 |
16 | 18 |
17 def Dispatch(options): | 19 def Dispatch(options): |
18 attached_devices = [] | 20 attached_devices = [] |
19 if options.test_device: | 21 if options.test_device: |
20 attached_devices = [options.test_device] | 22 attached_devices = [options.test_device] |
21 else: | 23 else: |
22 attached_devices = android_commands.GetAttachedDevices() | 24 attached_devices = android_commands.GetAttachedDevices() |
23 | 25 |
24 if not attached_devices: | 26 if not attached_devices: |
(...skipping 30 matching lines...) Expand all Loading... |
55 if options.gtest_filter: | 57 if options.gtest_filter: |
56 all_tests = [t for t in options.gtest_filter.split(':') if t] | 58 all_tests = [t for t in options.gtest_filter.split(':') if t] |
57 else: | 59 else: |
58 all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, | 60 all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, |
59 attached_devices) | 61 attached_devices) |
60 all_tests = _FilterTests(all_enabled) | 62 all_tests = _FilterTests(all_enabled) |
61 | 63 |
62 # Run tests. | 64 # Run tests. |
63 test_results = shard.ShardAndRunTests(RunnerFactory, attached_devices, | 65 test_results = shard.ShardAndRunTests(RunnerFactory, attached_devices, |
64 all_tests, options.build_type) | 66 all_tests, options.build_type) |
65 test_results.LogFull( | 67 report_results.LogFull( |
| 68 results=test_results, |
66 test_type='Unit test', | 69 test_type='Unit test', |
67 test_package=constants.BROWSERTEST_SUITE_NAME, | 70 test_package=constants.BROWSERTEST_SUITE_NAME, |
68 build_type=options.build_type, | 71 build_type=options.build_type, |
69 flakiness_server=options.flakiness_dashboard_server) | 72 flakiness_server=options.flakiness_dashboard_server) |
70 test_results.PrintAnnotation() | 73 report_results.PrintAnnotation(test_results) |
71 | 74 |
72 def _FilterTests(all_enabled_tests): | 75 def _FilterTests(all_enabled_tests): |
73 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" | 76 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
74 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] | 77 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
75 | 78 |
76 def _ShouldRunOnBot(test): | 79 def _ShouldRunOnBot(test): |
77 fixture, case = test.split('.', 1) | 80 fixture, case = test.split('.', 1) |
78 if _StartsWith(fixture, case, "PRE_"): | 81 if _StartsWith(fixture, case, "PRE_"): |
79 return False | 82 return False |
80 if _StartsWith(fixture, case, "MANUAL_"): | 83 if _StartsWith(fixture, case, "MANUAL_"): |
81 return False | 84 return False |
82 return True | 85 return True |
83 | 86 |
84 def _StartsWith(a, b, prefix): | 87 def _StartsWith(a, b, prefix): |
85 return a.startswith(prefix) or b.startswith(prefix) | 88 return a.startswith(prefix) or b.startswith(prefix) |
OLD | NEW |