| 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 fnmatch | 8 import fnmatch |
| 9 import glob | 9 import glob |
| 10 import logging | 10 import logging |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 'third_party/hunspell_dictionaries/*.dic', | 85 'third_party/hunspell_dictionaries/*.dic', |
| 86 # crbug.com/258690 | 86 # crbug.com/258690 |
| 87 'webkit/data/bmp_decoder', | 87 'webkit/data/bmp_decoder', |
| 88 'webkit/data/ico_decoder', | 88 'webkit/data/ico_decoder', |
| 89 ] | 89 ] |
| 90 | 90 |
| 91 _ISOLATE_SCRIPT = os.path.join( | 91 _ISOLATE_SCRIPT = os.path.join( |
| 92 constants.DIR_SOURCE_ROOT, 'tools', 'swarming_client', 'isolate.py') | 92 constants.DIR_SOURCE_ROOT, 'tools', 'swarming_client', 'isolate.py') |
| 93 | 93 |
| 94 | 94 |
| 95 def _GenerateDepsDirUsingIsolate(suite_name): | 95 def _GenerateDepsDirUsingIsolate(suite_name, isolate_file_path=None): |
| 96 """Generate the dependency dir for the test suite using isolate. | 96 """Generate the dependency dir for the test suite using isolate. |
| 97 | 97 |
| 98 Args: | 98 Args: |
| 99 suite_name: Name of the test suite (e.g. base_unittests). | 99 suite_name: Name of the test suite (e.g. base_unittests). |
| 100 isolate_file_path: .isolate file path to use. If there is a default .isolate |
| 101 file path for the suite_name, this will override it. |
| 100 """ | 102 """ |
| 101 if os.path.isdir(constants.ISOLATE_DEPS_DIR): | 103 if os.path.isdir(constants.ISOLATE_DEPS_DIR): |
| 102 shutil.rmtree(constants.ISOLATE_DEPS_DIR) | 104 shutil.rmtree(constants.ISOLATE_DEPS_DIR) |
| 103 | 105 |
| 104 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) | 106 if isolate_file_path: |
| 105 if not isolate_rel_path: | 107 if os.path.isabs(isolate_file_path): |
| 106 logging.info('Did not find an isolate file for the test suite.') | 108 isolate_abs_path = isolate_file_path |
| 107 return | 109 else: |
| 110 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, |
| 111 isolate_file_path) |
| 112 else: |
| 113 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) |
| 114 if not isolate_rel_path: |
| 115 logging.info('Did not find an isolate file for the test suite.') |
| 116 return |
| 117 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) |
| 108 | 118 |
| 109 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) | |
| 110 isolated_abs_path = os.path.join( | 119 isolated_abs_path = os.path.join( |
| 111 constants.GetOutDirectory(), '%s.isolated' % suite_name) | 120 constants.GetOutDirectory(), '%s.isolated' % suite_name) |
| 112 assert os.path.exists(isolate_abs_path) | 121 assert os.path.exists(isolate_abs_path) |
| 113 # This needs to be kept in sync with the cmd line options for isolate.py | 122 # This needs to be kept in sync with the cmd line options for isolate.py |
| 114 # in src/build/isolate.gypi. | 123 # in src/build/isolate.gypi. |
| 115 isolate_cmd = [ | 124 isolate_cmd = [ |
| 116 'python', _ISOLATE_SCRIPT, | 125 'python', _ISOLATE_SCRIPT, |
| 117 'remap', | 126 'remap', |
| 118 '--isolate', isolate_abs_path, | 127 '--isolate', isolate_abs_path, |
| 119 '--isolated', isolated_abs_path, | 128 '--isolated', isolated_abs_path, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 test_package = test_package_apk.TestPackageApk(test_options.suite_name) | 311 test_package = test_package_apk.TestPackageApk(test_options.suite_name) |
| 303 if not os.path.exists(test_package.suite_path): | 312 if not os.path.exists(test_package.suite_path): |
| 304 test_package = test_package_exe.TestPackageExecutable( | 313 test_package = test_package_exe.TestPackageExecutable( |
| 305 test_options.suite_name) | 314 test_options.suite_name) |
| 306 if not os.path.exists(test_package.suite_path): | 315 if not os.path.exists(test_package.suite_path): |
| 307 raise Exception( | 316 raise Exception( |
| 308 'Did not find %s target. Ensure it has been built.' | 317 'Did not find %s target. Ensure it has been built.' |
| 309 % test_options.suite_name) | 318 % test_options.suite_name) |
| 310 logging.warning('Found target %s', test_package.suite_path) | 319 logging.warning('Found target %s', test_package.suite_path) |
| 311 | 320 |
| 312 _GenerateDepsDirUsingIsolate(test_options.suite_name) | 321 _GenerateDepsDirUsingIsolate(test_options.suite_name, |
| 322 test_options.isolate_file_path) |
| 313 | 323 |
| 314 tests = _GetTests(test_options, test_package, devices) | 324 tests = _GetTests(test_options, test_package, devices) |
| 315 | 325 |
| 316 # Constructs a new TestRunner with the current options. | 326 # Constructs a new TestRunner with the current options. |
| 317 def TestRunnerFactory(device, _shard_index): | 327 def TestRunnerFactory(device, _shard_index): |
| 318 return test_runner.TestRunner( | 328 return test_runner.TestRunner( |
| 319 test_options, | 329 test_options, |
| 320 device, | 330 device, |
| 321 test_package) | 331 test_package) |
| 322 | 332 |
| 323 if test_options.run_disabled: | 333 if test_options.run_disabled: |
| 324 test_options = test_options._replace( | 334 test_options = test_options._replace( |
| 325 test_arguments=('%s --gtest_also_run_disabled_tests' % | 335 test_arguments=('%s --gtest_also_run_disabled_tests' % |
| 326 test_options.test_arguments)) | 336 test_options.test_arguments)) |
| 327 else: | 337 else: |
| 328 tests = _FilterDisabledTests(tests, test_options.suite_name, | 338 tests = _FilterDisabledTests(tests, test_options.suite_name, |
| 329 bool(test_options.gtest_filter)) | 339 bool(test_options.gtest_filter)) |
| 330 if test_options.gtest_filter: | 340 if test_options.gtest_filter: |
| 331 tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) | 341 tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) |
| 332 | 342 |
| 333 # Coalesce unit tests into a single test per device | 343 # Coalesce unit tests into a single test per device |
| 334 if test_options.suite_name != 'content_browsertests': | 344 if test_options.suite_name != 'content_browsertests': |
| 335 num_devices = len(devices) | 345 num_devices = len(devices) |
| 336 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 346 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
| 337 tests = [t for t in tests if t] | 347 tests = [t for t in tests if t] |
| 338 | 348 |
| 339 return (TestRunnerFactory, tests) | 349 return (TestRunnerFactory, tests) |
| OLD | NEW |