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