| 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 | 7 |
| 7 import fnmatch | 8 import fnmatch |
| 8 import glob | 9 import glob |
| 9 import logging | 10 import logging |
| 10 import os | 11 import os |
| 11 import shutil | 12 import shutil |
| 12 import sys | 13 import sys |
| 13 | 14 |
| 14 from pylib import android_commands | 15 from pylib import android_commands |
| 15 from pylib import cmd_helper | 16 from pylib import cmd_helper |
| 16 from pylib import constants | 17 from pylib import constants |
| 17 from pylib import ports | |
| 18 | 18 |
| 19 import test_package_apk | 19 from pylib.gtest import test_package_apk |
| 20 import test_package_exe | 20 from pylib.gtest import test_package_exe |
| 21 import test_runner | 21 from pylib.gtest import test_runner |
| 22 | 22 |
| 23 sys.path.insert(0, | 23 sys.path.insert(0, |
| 24 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', | 24 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', |
| 25 'common')) | 25 'common')) |
| 26 import unittest_util | 26 import unittest_util |
| 27 | 27 |
| 28 | 28 |
| 29 _ISOLATE_FILE_PATHS = { | 29 _ISOLATE_FILE_PATHS = { |
| 30 'base_unittests': 'base/base_unittests.isolate', | 30 'base_unittests': 'base/base_unittests.isolate', |
| 31 'breakpad_unittests': 'breakpad/breakpad_unittests.isolate', | 31 'breakpad_unittests': 'breakpad/breakpad_unittests.isolate', |
| (...skipping 22 matching lines...) Expand all Loading... |
| 54 'system_wrappers_unittests': | 54 'system_wrappers_unittests': |
| 55 'system_wrappers/source/system_wrappers_unittests.isolate', | 55 'system_wrappers/source/system_wrappers_unittests.isolate', |
| 56 'test_support_unittests': 'test/test_support_unittests.isolate', | 56 'test_support_unittests': 'test/test_support_unittests.isolate', |
| 57 'tools_unittests': 'tools/tools_unittests.isolate', | 57 'tools_unittests': 'tools/tools_unittests.isolate', |
| 58 'video_engine_core_unittests': | 58 'video_engine_core_unittests': |
| 59 'video_engine/video_engine_core_unittests.isolate', | 59 'video_engine/video_engine_core_unittests.isolate', |
| 60 'voice_engine_unittests': 'voice_engine/voice_engine_unittests.isolate', | 60 'voice_engine_unittests': 'voice_engine/voice_engine_unittests.isolate', |
| 61 } | 61 } |
| 62 | 62 |
| 63 # Append the WebRTC tests with the full path from Chromium's src/ root. | 63 # Append the WebRTC tests with the full path from Chromium's src/ root. |
| 64 for test, isolate_path in _WEBRTC_ISOLATE_FILE_PATHS.items(): | 64 for webrtc_test, isolate_path in _WEBRTC_ISOLATE_FILE_PATHS.items(): |
| 65 _ISOLATE_FILE_PATHS[test] = 'third_party/webrtc/%s' % isolate_path | 65 _ISOLATE_FILE_PATHS[webrtc_test] = 'third_party/webrtc/%s' % isolate_path |
| 66 | 66 |
| 67 # Used for filtering large data deps at a finer grain than what's allowed in | 67 # Used for filtering large data deps at a finer grain than what's allowed in |
| 68 # isolate files since pushing deps to devices is expensive. | 68 # isolate files since pushing deps to devices is expensive. |
| 69 # Wildcards are allowed. | 69 # Wildcards are allowed. |
| 70 _DEPS_EXCLUSION_LIST = [ | 70 _DEPS_EXCLUSION_LIST = [ |
| 71 'chrome/test/data/extensions/api_test', | 71 'chrome/test/data/extensions/api_test', |
| 72 'chrome/test/data/extensions/secure_shell', | 72 'chrome/test/data/extensions/secure_shell', |
| 73 'chrome/test/data/firefox*', | 73 'chrome/test/data/firefox*', |
| 74 'chrome/test/data/gpu', | 74 'chrome/test/data/gpu', |
| 75 'chrome/test/data/image_decoding', | 75 'chrome/test/data/image_decoding', |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 test_options.suite_name) | 286 test_options.suite_name) |
| 287 if not os.path.exists(test_package.suite_path): | 287 if not os.path.exists(test_package.suite_path): |
| 288 raise Exception( | 288 raise Exception( |
| 289 'Did not find %s target. Ensure it has been built.' | 289 'Did not find %s target. Ensure it has been built.' |
| 290 % test_options.suite_name) | 290 % test_options.suite_name) |
| 291 logging.warning('Found target %s', test_package.suite_path) | 291 logging.warning('Found target %s', test_package.suite_path) |
| 292 | 292 |
| 293 _GenerateDepsDirUsingIsolate(test_options.suite_name) | 293 _GenerateDepsDirUsingIsolate(test_options.suite_name) |
| 294 | 294 |
| 295 # Constructs a new TestRunner with the current options. | 295 # Constructs a new TestRunner with the current options. |
| 296 def TestRunnerFactory(device, shard_index): | 296 def TestRunnerFactory(device, _shard_index): |
| 297 return test_runner.TestRunner( | 297 return test_runner.TestRunner( |
| 298 test_options, | 298 test_options, |
| 299 device, | 299 device, |
| 300 test_package) | 300 test_package) |
| 301 | 301 |
| 302 tests = _GetTestsFromDevice(TestRunnerFactory, devices) | 302 tests = _GetTestsFromDevice(TestRunnerFactory, devices) |
| 303 if test_options.run_disabled: | 303 if test_options.run_disabled: |
| 304 test_options = test_options._replace( | 304 test_options = test_options._replace( |
| 305 test_arguments=('%s --gtest_also_run_disabled_tests' % | 305 test_arguments=('%s --gtest_also_run_disabled_tests' % |
| 306 test_options.test_arguments)) | 306 test_options.test_arguments)) |
| 307 else: | 307 else: |
| 308 tests = _FilterDisabledTests(tests, test_options.suite_name, | 308 tests = _FilterDisabledTests(tests, test_options.suite_name, |
| 309 bool(test_options.gtest_filter)) | 309 bool(test_options.gtest_filter)) |
| 310 if test_options.gtest_filter: | 310 if test_options.gtest_filter: |
| 311 tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) | 311 tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) |
| 312 | 312 |
| 313 # Coalesce unit tests into a single test per device | 313 # Coalesce unit tests into a single test per device |
| 314 if test_options.suite_name != 'content_browsertests': | 314 if test_options.suite_name != 'content_browsertests': |
| 315 num_devices = len(devices) | 315 num_devices = len(devices) |
| 316 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 316 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
| 317 tests = [t for t in tests if t] | 317 tests = [t for t in tests if t] |
| 318 | 318 |
| 319 return (TestRunnerFactory, tests) | 319 return (TestRunnerFactory, tests) |
| OLD | NEW |