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 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 _ISOLATE_SCRIPT = os.path.join( | 89 _ISOLATE_SCRIPT = os.path.join( |
90 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') | 90 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') |
91 | 91 |
92 | 92 |
93 def _GenerateDepsDirUsingIsolate(suite_name): | 93 def _GenerateDepsDirUsingIsolate(suite_name): |
94 """Generate the dependency dir for the test suite using isolate. | 94 """Generate the dependency dir for the test suite using isolate. |
95 | 95 |
96 Args: | 96 Args: |
97 suite_name: Name of the test suite (e.g. base_unittests). | 97 suite_name: Name of the test suite (e.g. base_unittests). |
98 """ | 98 """ |
| 99 product_dir = os.path.join(cmd_helper.OutDirectory.get(), |
| 100 constants.GetBuildType()) |
| 101 assert os.path.isabs(product_dir) |
| 102 |
99 if os.path.isdir(constants.ISOLATE_DEPS_DIR): | 103 if os.path.isdir(constants.ISOLATE_DEPS_DIR): |
100 shutil.rmtree(constants.ISOLATE_DEPS_DIR) | 104 shutil.rmtree(constants.ISOLATE_DEPS_DIR) |
101 | 105 |
102 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) | 106 isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) |
103 if not isolate_rel_path: | 107 if not isolate_rel_path: |
104 logging.info('Did not find an isolate file for the test suite.') | 108 logging.info('Did not find an isolate file for the test suite.') |
105 return | 109 return |
106 | 110 |
107 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) | 111 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) |
108 isolated_abs_path = os.path.join( | 112 isolated_abs_path = os.path.join( |
109 constants.GetOutDirectory(), '%s.isolated' % suite_name) | 113 product_dir, '%s.isolated' % suite_name) |
110 assert os.path.exists(isolate_abs_path) | 114 assert os.path.exists(isolate_abs_path) |
111 isolate_cmd = [ | 115 isolate_cmd = [ |
112 'python', _ISOLATE_SCRIPT, | 116 'python', _ISOLATE_SCRIPT, |
113 'remap', | 117 'remap', |
114 '--isolate', isolate_abs_path, | 118 '--isolate', isolate_abs_path, |
115 '--isolated', isolated_abs_path, | 119 '--isolated', isolated_abs_path, |
116 '-V', 'PRODUCT_DIR=%s' % constants.GetOutDirectory(), | 120 '-V', 'PRODUCT_DIR=%s' % product_dir, |
117 '-V', 'OS=android', | 121 '-V', 'OS=android', |
118 '--outdir', constants.ISOLATE_DEPS_DIR, | 122 '--outdir', constants.ISOLATE_DEPS_DIR, |
119 ] | 123 ] |
120 assert not cmd_helper.RunCmd(isolate_cmd) | 124 assert not cmd_helper.RunCmd(isolate_cmd) |
121 | 125 |
122 # We're relying on the fact that timestamps are preserved | 126 # We're relying on the fact that timestamps are preserved |
123 # by the remap command (hardlinked). Otherwise, all the data | 127 # by the remap command (hardlinked). Otherwise, all the data |
124 # will be pushed to the device once we move to using time diff | 128 # will be pushed to the device once we move to using time diff |
125 # instead of md5sum. Perform a sanity check here. | 129 # instead of md5sum. Perform a sanity check here. |
126 for root, _, filenames in os.walk(constants.ISOLATE_DEPS_DIR): | 130 for root, _, filenames in os.walk(constants.ISOLATE_DEPS_DIR): |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 314 |
311 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter, | 315 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter, |
312 TestRunnerFactory, devices) | 316 TestRunnerFactory, devices) |
313 # Coalesce unit tests into a single test per device | 317 # Coalesce unit tests into a single test per device |
314 if test_options.suite_name != 'content_browsertests': | 318 if test_options.suite_name != 'content_browsertests': |
315 num_devices = len(devices) | 319 num_devices = len(devices) |
316 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 320 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
317 tests = [t for t in tests if t] | 321 tests = [t for t in tests if t] |
318 | 322 |
319 return (TestRunnerFactory, tests) | 323 return (TestRunnerFactory, tests) |
OLD | NEW |