| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 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 """Generates test runner factory and tests for GTests.""" | 5 """Generates test runner factory and tests for GTests.""" |
| 6 # pylint: disable=W0212 | 6 # pylint: disable=W0212 |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 if not os.path.exists(exe_test_package.suite_path): | 200 if not os.path.exists(exe_test_package.suite_path): |
| 201 raise Exception( | 201 raise Exception( |
| 202 'Did not find %s target. Ensure it has been built.\n' | 202 'Did not find %s target. Ensure it has been built.\n' |
| 203 '(not found at %s or %s)' | 203 '(not found at %s or %s)' |
| 204 % (test_options.suite_name, | 204 % (test_options.suite_name, |
| 205 test_package.suite_path, | 205 test_package.suite_path, |
| 206 exe_test_package.suite_path)) | 206 exe_test_package.suite_path)) |
| 207 test_package = exe_test_package | 207 test_package = exe_test_package |
| 208 logging.warning('Found target %s', test_package.suite_path) | 208 logging.warning('Found target %s', test_package.suite_path) |
| 209 | 209 |
| 210 base_setup.GenerateDepsDirUsingIsolate(test_options.suite_name, | 210 i = base_setup.GenerateDepsDirUsingIsolate(test_options.suite_name, |
| 211 test_options.isolate_file_path, | 211 test_options.isolate_file_path, |
| 212 ISOLATE_FILE_PATHS, | 212 ISOLATE_FILE_PATHS, |
| 213 DEPS_EXCLUSION_LIST) | 213 DEPS_EXCLUSION_LIST) |
| 214 def push_data_deps_to_device_dir(device): | 214 def push_data_deps_to_device_dir(device): |
| 215 device_dir = (constants.TEST_EXECUTABLE_DIR | 215 device_dir = (constants.TEST_EXECUTABLE_DIR |
| 216 if test_package.suite_name == 'breakpad_unittests' | 216 if test_package.suite_name == 'breakpad_unittests' |
| 217 else device.GetExternalStoragePath()) | 217 else device.GetExternalStoragePath()) |
| 218 base_setup.PushDataDeps(device, device_dir, test_options) | 218 base_setup.PushDataDeps(device, device_dir, test_options) |
| 219 device_utils.DeviceUtils.parallel(devices).pMap(push_data_deps_to_device_dir) | 219 device_utils.DeviceUtils.parallel(devices).pMap(push_data_deps_to_device_dir) |
| 220 if i: |
| 221 i.Clear() |
| 220 | 222 |
| 221 tests = _GetTests(test_options, test_package, devices) | 223 tests = _GetTests(test_options, test_package, devices) |
| 222 | 224 |
| 223 # Constructs a new TestRunner with the current options. | 225 # Constructs a new TestRunner with the current options. |
| 224 def TestRunnerFactory(device, _shard_index): | 226 def TestRunnerFactory(device, _shard_index): |
| 225 return test_runner.TestRunner( | 227 return test_runner.TestRunner( |
| 226 test_options, | 228 test_options, |
| 227 device, | 229 device, |
| 228 test_package) | 230 test_package) |
| 229 | 231 |
| 230 if test_options.run_disabled: | 232 if test_options.run_disabled: |
| 231 test_options = test_options._replace( | 233 test_options = test_options._replace( |
| 232 test_arguments=('%s --gtest_also_run_disabled_tests' % | 234 test_arguments=('%s --gtest_also_run_disabled_tests' % |
| 233 test_options.test_arguments)) | 235 test_options.test_arguments)) |
| 234 else: | 236 else: |
| 235 tests = _FilterDisabledTests(tests, test_options.suite_name, | 237 tests = _FilterDisabledTests(tests, test_options.suite_name, |
| 236 bool(test_options.gtest_filter)) | 238 bool(test_options.gtest_filter)) |
| 237 if test_options.gtest_filter: | 239 if test_options.gtest_filter: |
| 238 tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) | 240 tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) |
| 239 | 241 |
| 240 # Coalesce unit tests into a single test per device | 242 # Coalesce unit tests into a single test per device |
| 241 if (test_options.suite_name != 'content_browsertests' and | 243 if (test_options.suite_name != 'content_browsertests' and |
| 242 test_options.suite_name != 'components_browsertests'): | 244 test_options.suite_name != 'components_browsertests'): |
| 243 num_devices = len(devices) | 245 num_devices = len(devices) |
| 244 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 246 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
| 245 tests = [t for t in tests if t] | 247 tests = [t for t in tests if t] |
| 246 | 248 |
| 247 return (TestRunnerFactory, tests) | 249 return (TestRunnerFactory, tests) |
| OLD | NEW |