| 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 shutil |
| 9 import sys | 10 import sys |
| 10 | 11 |
| 11 from pylib import android_commands | 12 from pylib import android_commands |
| 12 from pylib import cmd_helper | 13 from pylib import cmd_helper |
| 13 from pylib import constants | 14 from pylib import constants |
| 14 from pylib import ports | 15 from pylib import ports |
| 15 from pylib.base import base_test_result | 16 from pylib.base import base_test_result |
| 16 from pylib.base import shard | 17 from pylib.base import shard |
| 17 from pylib.gtest import dispatch as gtest_dispatch | 18 from pylib.gtest import dispatch as gtest_dispatch |
| 18 from pylib.gtest import test_runner | 19 from pylib.gtest import test_runner |
| (...skipping 29 matching lines...) Expand all Loading... |
| 48 # to dispatch any tests. | 49 # to dispatch any tests. |
| 49 if not ports.ResetTestServerPortAllocation(): | 50 if not ports.ResetTestServerPortAllocation(): |
| 50 raise Exception('Failed to reset test server port.') | 51 raise Exception('Failed to reset test server port.') |
| 51 | 52 |
| 52 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), | 53 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), |
| 53 options.build_type) | 54 options.build_type) |
| 54 options.test_suite = os.path.join(test_suite_dir, | 55 options.test_suite = os.path.join(test_suite_dir, |
| 55 'apks', | 56 'apks', |
| 56 constants.BROWSERTEST_SUITE_NAME + '.apk') | 57 constants.BROWSERTEST_SUITE_NAME + '.apk') |
| 57 | 58 |
| 58 deps_dir = gtest_dispatch._GenerateDepsDirUsingIsolate( | 59 gtest_dispatch._GenerateDepsDirUsingIsolate( |
| 59 constants.BROWSERTEST_SUITE_NAME, options.build_type) | 60 constants.BROWSERTEST_SUITE_NAME, options.build_type) |
| 60 | 61 |
| 61 # Constructs a new TestRunner with the current options. | 62 # Constructs a new TestRunner with the current options. |
| 62 def RunnerFactory(device, shard_index): | 63 def RunnerFactory(device, shard_index): |
| 63 return test_runner.TestRunner( | 64 return test_runner.TestRunner( |
| 64 device, | 65 device, |
| 65 options.test_suite, | 66 options.test_suite, |
| 66 options.test_arguments, | 67 options.test_arguments, |
| 67 options.timeout, | 68 options.timeout, |
| 68 options.cleanup_test_files, | 69 options.cleanup_test_files, |
| 69 options.tool, | 70 options.tool, |
| 70 options.build_type, | 71 options.build_type, |
| 71 options.webkit, | 72 options.webkit, |
| 72 options.push_deps, | 73 options.push_deps, |
| 73 constants.BROWSERTEST_TEST_PACKAGE_NAME, | 74 constants.BROWSERTEST_TEST_PACKAGE_NAME, |
| 74 constants.BROWSERTEST_TEST_ACTIVITY_NAME, | 75 constants.BROWSERTEST_TEST_ACTIVITY_NAME, |
| 75 constants.BROWSERTEST_COMMAND_LINE_FILE, | 76 constants.BROWSERTEST_COMMAND_LINE_FILE) |
| 76 deps_dir=deps_dir) | |
| 77 | 77 |
| 78 # Get tests and split them up based on the number of devices. | 78 # Get tests and split them up based on the number of devices. |
| 79 all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, | 79 all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, |
| 80 attached_devices) | 80 attached_devices) |
| 81 if options.test_filter: | 81 if options.test_filter: |
| 82 all_tests = unittest_util.FilterTestNames(all_enabled, | 82 all_tests = unittest_util.FilterTestNames(all_enabled, |
| 83 options.test_filter) | 83 options.test_filter) |
| 84 else: | 84 else: |
| 85 all_tests = _FilterTests(all_enabled) | 85 all_tests = _FilterTests(all_enabled) |
| 86 | 86 |
| 87 # Run tests. | 87 # Run tests. |
| 88 # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer | 88 # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer |
| 89 # files are pushed to the devices for content_browsertests: crbug.com/138275 | 89 # files are pushed to the devices for content_browsertests: crbug.com/138275 |
| 90 setup_timeout = 20 * 60 # 20 minutes | 90 setup_timeout = 20 * 60 # 20 minutes |
| 91 test_results, exit_code = shard.ShardAndRunTests( | 91 test_results, exit_code = shard.ShardAndRunTests( |
| 92 RunnerFactory, attached_devices, all_tests, options.build_type, | 92 RunnerFactory, attached_devices, all_tests, options.build_type, |
| 93 setup_timeout=setup_timeout, test_timeout=None, | 93 setup_timeout=setup_timeout, test_timeout=None, |
| 94 num_retries=options.num_retries) | 94 num_retries=options.num_retries) |
| 95 report_results.LogFull( | 95 report_results.LogFull( |
| 96 results=test_results, | 96 results=test_results, |
| 97 test_type='Unit test', | 97 test_type='Unit test', |
| 98 test_package=constants.BROWSERTEST_SUITE_NAME, | 98 test_package=constants.BROWSERTEST_SUITE_NAME, |
| 99 build_type=options.build_type, | 99 build_type=options.build_type, |
| 100 flakiness_server=options.flakiness_dashboard_server) | 100 flakiness_server=options.flakiness_dashboard_server) |
| 101 | 101 |
| 102 if os.path.isdir(constants.ISOLATE_DEPS_DIR): |
| 103 shutil.rmtree(constants.ISOLATE_DEPS_DIR) |
| 104 |
| 102 return (test_results, exit_code) | 105 return (test_results, exit_code) |
| 103 | 106 |
| 104 | 107 |
| 105 def _FilterTests(all_enabled_tests): | 108 def _FilterTests(all_enabled_tests): |
| 106 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" | 109 """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
| 107 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] | 110 return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
| 108 | 111 |
| 109 | 112 |
| 110 def _ShouldRunOnBot(test): | 113 def _ShouldRunOnBot(test): |
| 111 fixture, case = test.split('.', 1) | 114 fixture, case = test.split('.', 1) |
| 112 if _StartsWith(fixture, case, 'PRE_'): | 115 if _StartsWith(fixture, case, 'PRE_'): |
| 113 return False | 116 return False |
| 114 if _StartsWith(fixture, case, 'MANUAL_'): | 117 if _StartsWith(fixture, case, 'MANUAL_'): |
| 115 return False | 118 return False |
| 116 return True | 119 return True |
| 117 | 120 |
| 118 | 121 |
| 119 def _StartsWith(a, b, prefix): | 122 def _StartsWith(a, b, prefix): |
| 120 return a.startswith(prefix) or b.startswith(prefix) | 123 return a.startswith(prefix) or b.startswith(prefix) |
| OLD | NEW |