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